<!DOCTYPE html><html lang="en"><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><meta name="generator" content="ReSpec 21.0.2"><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"><style>/* --- EXAMPLES --- */
div.example-title {
    min-width: 7.5em;
    color: #b9ab2d;
}
div.example-title span {
    text-transform: uppercase;
}
aside.example, div.example, div.illegal-example {
    padding: 0.5em;
    margin: 1em 0;
    position: relative;
    clear: both;
}
div.illegal-example { color: red }
div.illegal-example p { color: black }
aside.example, div.example {
    padding: .5em;
    border-left-width: .5em;
    border-left-style: solid;
    border-color: #e0cb52;
    background: #fcfaee;
}

aside.example div.example {
    border-left-width: .1em;
    border-color: #999;
    background: #fff;
}
aside.example div.example div.example-title {
    color: #999;
}
</style><style>/* --- ISSUES/NOTES --- */
div.issue-title, div.note-title , div.ednote-title, div.warning-title {
    padding-right:  1em;
    min-width: 7.5em;
    color: #b9ab2d;
}
div.issue-title { color: #e05252; }
div.note-title, div.ednote-title { color: #2b2; }
div.warning-title { color: #f22; }
div.issue-title span, div.note-title span, div.ednote-title span, div.warning-title span {
    text-transform: uppercase;
}
div.note, div.issue, div.ednote, div.warning {
    margin-top: 1em;
    margin-bottom: 1em;
}
.note > p:first-child, .ednote > p:first-child, .issue > p:first-child, .warning > p:first-child { margin-top: 0 }
.issue, .note, .ednote, .warning {
    padding: .5em;
    border-left-width: .5em;
    border-left-style: solid;
}
div.issue, div.note , div.ednote,  div.warning {
    padding: 1em 1.2em 0.5em;
    margin: 1em 0;
    position: relative;
    clear: both;
}
span.note, span.ednote, span.issue, span.warning { padding: .1em .5em .15em; }

.issue {
    border-color: #e05252;
    background: #fbe9e9;
}
.note, .ednote {
    border-color: #52e052;
    background: #e9fbe9;
}

.warning {
    border-color: #f11;
    border-width: .2em;
    border-style: solid;
    background: #fbe9e9;
}

.warning-title:before{
    content: "⚠"; /*U+26A0 WARNING SIGN*/
    font-size: 3em;
    float: left;
    height: 100%;
    padding-right: .3em;
    vertical-align: top;
    margin-top: -0.5em;
}

li.task-list-item {
    list-style: none;
}

input.task-list-item-checkbox {
    margin: 0 0.35em 0.25em -1.6em;
    vertical-align: middle;
}

.issue a.respec-gh-label {
  padding: 5px;
  margin: 0 2px 0 2px;
  font-size: 10px;
  text-transform: none;
  text-decoration: none;
  font-weight: bold;
  border-radius: 4px;
  position: relative;
  bottom: 2px;
}

.issue a.respec-label-dark {
  color: #fff;
  background-color: #000;
}

.issue a.respec-label-light {
  color: #000;
  background-color: #fff;
}
</style><style>/* --- WEB IDL --- */

pre.idl {
  padding: 1em;
}

.respec-idl-separator {
  padding: 0 0 0.4cm 0;
}

.respec-idl-separator:last-child {
  padding: 0;
}

@media print {
  pre.idl {
    white-space: pre-wrap;
  }
}

pre.idl::before {
  content: "WebIDL";
  display: block;
  width: 150px;
  background: #90b8de;
  color: #fff;
  font-family: sans-serif;
  font-weight: bold;
  margin: -1em 0 1em -1em;
  height: 28px;
  line-height: 28px;
}

.idlType {
  color: #ff4500;
  font-weight: bold;
  text-decoration: none;
}


/*.idlModule*/


/*.idlModuleID*/


/*.idlInterface*/

.idlInterfaceID,
.idlDictionaryID,
.idlCallbackID,
.idlEnumID {
  font-weight: bold;
  color: #005a9c;
}

a.idlEnumItem {
  color: #000;
  border-bottom: 1px dotted #ccc;
  text-decoration: none;
}

.idlSuperclass {
  font-style: italic;
  color: #005a9c;
}


/*.idlAttribute*/

.idlAttrType,
.idlFieldType,
.idlMemberType {
  color: #005a9c;
}

.idlAttrName,
.idlFieldName,
.idlMemberName {
  color: #ff4500;
}

.idlAttrName a,
.idlFieldName a,
.idlMemberName a {
  color: #ff4500;
  border-bottom: 1px dotted #ff4500;
  text-decoration: none;
}


/*.idlMethod*/

.idlMethType,
.idlCallbackType {
  color: #005a9c;
}

.idlMethName {
  color: #ff4500;
}

.idlMethName a {
  color: #ff4500;
  border-bottom: 1px dotted #ff4500;
  text-decoration: none;
}


/*.idlCtor*/

.idlCtorName {
  color: #ff4500;
}

.idlCtorName a {
  color: #ff4500;
  border-bottom: 1px dotted #ff4500;
  text-decoration: none;
}


/*.idlParam*/

.idlParamType {
  color: #005a9c;
}

.idlParamName,
.idlDefaultValue {
  font-style: italic;
}

.extAttr {
  color: #666;
}


/*.idlSectionComment*/

.idlSectionComment {
  color: gray;
}


/*.idlIterable*/

.idlIterableKeyType,
.idlIterableValueType {
  color: #005a9c;
}


/*.idlMaplike*/

.idlMaplikeKeyType,
.idlMaplikeValueType {
  color: #005a9c;
}


/*.idlConst*/

.idlConstType {
  color: #005a9c;
}

.idlConstName {
  color: #ff4500;
}

.idlConstName a {
  color: #ff4500;
  border-bottom: 1px dotted #ff4500;
  text-decoration: none;
}


/*.idlException*/

.idlExceptionID {
  font-weight: bold;
  color: #c00;
}

.idlTypedefID,
.idlTypedefType {
  color: #005a9c;
}

.idlRaises,
.idlRaises a.idlType,
.idlRaises a.idlType code,
.excName a,
.excName a code {
  color: #c00;
  font-weight: normal;
}

.excName a {
  font-family: monospace;
}

.idlRaises a.idlType,
.excName a.idlType {
  border-bottom: 1px dotted #c00;
}

.excGetSetTrue,
.excGetSetFalse,
.prmNullTrue,
.prmNullFalse,
.prmOptTrue,
.prmOptFalse {
  width: 45px;
  text-align: center;
}

.excGetSetTrue,
.prmNullTrue,
.prmOptTrue {
  color: #0c0;
}

.excGetSetFalse,
.prmNullFalse,
.prmOptFalse {
  color: #c00;
}

.idlImplements a, .idlIncludes a {
  font-weight: bold;
}

dl.attributes,
dl.methods,
dl.constants,
dl.constructors,
dl.fields,
dl.dictionary-members {
  margin-left: 2em;
}

.attributes dt,
.methods dt,
.constants dt,
.constructors dt,
.fields dt,
.dictionary-members dt {
  font-weight: normal;
}

.attributes dt code,
.methods dt code,
.constants dt code,
.constructors dt code,
.fields dt code,
.dictionary-members dt code {
  font-weight: bold;
  color: #000;
  font-family: monospace;
}

.attributes dt code,
.fields dt code,
.dictionary-members dt code {
  background: #ffffd2;
}

.attributes dt .idlAttrType code,
.fields dt .idlFieldType code,
.dictionary-members dt .idlMemberType code {
  color: #005a9c;
  background: transparent;
  font-family: inherit;
  font-weight: normal;
  font-style: italic;
}

.methods dt code {
  background: #d9e6f8;
}

.constants dt code {
  background: #ddffd2;
}

.constructors dt code {
  background: #cfc;
}

.attributes dd,
.methods dd,
.constants dd,
.constructors dd,
.fields dd,
.dictionary-members dd {
  margin-bottom: 1em;
}

table.parameters,
table.exceptions {
  border-spacing: 0;
  border-collapse: collapse;
  margin: 0.5em 0;
  width: 100%;
}

table.parameters {
  border-bottom: 1px solid #90b8de;
}

table.exceptions {
  border-bottom: 1px solid #deb890;
}

.parameters th,
.exceptions th {
  color: inherit;
  padding: 3px 5px;
  text-align: left;
  font-weight: normal;
}

.parameters th {
  color: #fff;
  background: #005a9c;
}

.exceptions th {
  background: #deb890;
}

.parameters td,
.exceptions td {
  padding: 3px 10px;
  border-top: 1px solid #ddd;
  vertical-align: top;
}

.parameters tr:first-child td,
.exceptions tr:first-child td {
  border-top: none;
}

.parameters td.prmName,
.exceptions td.excName,
.exceptions td.excCodeName {
  width: 100px;
}

.parameters td.prmType {
  width: 120px;
}

table.exceptions table {
  border-spacing: 0;
  border-collapse: collapse;
  width: 100%;
}

.respec-button-copy-paste:focus {
  text-decoration: none;
  border-color: #51a7e8;
  outline: none;
  box-shadow: 0 0 5px rgba(81, 167, 232, 0.5);
}

.respec-button-copy-paste:focus:hover,
.respec-button-copy-paste.selected:focus {
  border-color: #51a7e8;
}

.respec-button-copy-paste:hover,
.respec-button-copy-paste:active,
.respec-button-copy-paste.zeroclipboard-is-hover,
.respec-button-copy-paste.zeroclipboard-is-active {
  text-decoration: none;
  background-color: #ddd;
  background-image: linear-gradient(#eee, #ddd);
  border-color: #ccc;
}

.respec-button-copy-paste:active,
.respec-button-copy-paste.selected,
.respec-button-copy-paste.zeroclipboard-is-active {
  background-color: #dcdcdc;
  background-image: none;
  border-color: #b5b5b5;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15)
}

.respec-button-copy-paste.selected:hover {
  background-color: #cfcfcf;
}

.respec-button-copy-paste:disabled,
.respec-button-copy-paste:disabled:hover,
.respec-button-copy-paste.disabled,
.respec-button-copy-paste.disabled:hover {
  color: rgba(102, 102, 102, 0.5);
  cursor: default;
  background-color: rgba(229, 229, 229, 0.5);
  background-image: none;
  border-color: rgba(197, 197, 197, 0.5);
  box-shadow: none;
}
</style><style>/* --- PERMALINKS --- */

.permalink {
  width: 1px;
  height: 1px;
  overflow: visible;
  font-size: 10pt;
  font-style: normal;
  vertical-align: middle;
  margin-left: 4px;
}

.permalink a, .permalink a:link, .permalink a:visited, .permalink a:hover, .permalink a:focus, .permalink a:active {
  background:transparent !important;
  text-decoration:none;
  font-weight: bold;
  color:#666 !important;
}

.permalink abbr {
  border:0;
}
</style>
<title>JSON-LD 1.1 Processing Algorithms and API</title>




<style type="text/css">
  .hl-bold {
    font-weight: bold;
    color: #0a3;
  }
  .comment {
    color: #999;
  }
  .error a {
    color:  #ff4500;
    border-bottom:  1px dotted #ff4500;
    text-decoration: none;
  }
  .algorithm ol {
    counter-reset: numsection;
    list-style-type: none;
  }
  .algorithm li {
    margin: 0.5em 0;
  }
  .algorithm li:before {
    font-weight: bold;
    counter-increment: numsection;
    content: counters(numsection, ".") ") ";
  }
  .changed {
    background-color: rgb(215, 238, 197);
  }
  .changed:hover {
    color:  green;
    background-color: inherit;
  }
</style>
<style id="respec-mainstyle">/*****************************************************************
 * ReSpec 3 CSS
 * Robin Berjon - http://berjon.com/
 *****************************************************************/

/* Override code highlighter background */
.hljs {
  background: transparent !important;
}

/* --- INLINES --- */
h1 abbr,
h2 abbr,
h3 abbr,
h4 abbr,
h5 abbr,
h6 abbr,
a abbr {
  border: none;
}

dfn {
  font-weight: bold;
}

a.internalDFN {
  color: inherit;
  border-bottom: 1px solid #99c;
  text-decoration: none;
}

a.externalDFN {
  color: inherit;
  border-bottom: 1px dotted #ccc;
  text-decoration: none;
}

a.bibref {
  text-decoration: none;
}

cite .bibref {
  font-style: normal;
}

code {
  color: #c83500;
}

th code {
  color: inherit;
}

/* --- TOC --- */

.toc a,
.tof a {
  text-decoration: none;
}

a .secno,
a .figno {
  color: #000;
}

ul.tof,
ol.tof {
  list-style: none outside none;
}

.caption {
  margin-top: 0.5em;
  font-style: italic;
}

/* --- TABLE --- */

table.simple {
  border-spacing: 0;
  border-collapse: collapse;
  border-bottom: 3px solid #005a9c;
}

.simple th {
  background: #005a9c;
  color: #fff;
  padding: 3px 5px;
  text-align: left;
}

.simple th[scope="row"] {
  background: inherit;
  color: inherit;
  border-top: 1px solid #ddd;
}

.simple td {
  padding: 3px 10px;
  border-top: 1px solid #ddd;
}

.simple tr:nth-child(even) {
  background: #f0f6ff;
}

/* --- DL --- */

.section dd > p:first-child {
  margin-top: 0;
}

.section dd > p:last-child {
  margin-bottom: 0;
}

.section dd {
  margin-bottom: 1em;
}

.section dl.attrs dd,
.section dl.eldef dd {
  margin-bottom: 0;
}

#issue-summary > ul,
.respec-dfn-list {
  column-count: 2;
}

#issue-summary li,
.respec-dfn-list li {
  list-style: none;
}

details.respec-tests-details {
  margin-left: 1em;
  display: inline-block;
  vertical-align: top;
}

details.respec-tests-details > * {
  padding-right: 2em;
}

details.respec-tests-details[open] {
  z-index: 999999;
  position: absolute;
  border: thin solid #cad3e2;
  border-radius: .3em;
  background-color: white;
  padding-bottom: .5em;
}

details.respec-tests-details[open] > summary {
  border-bottom: thin solid #cad3e2;
  padding-left: 1em;
  margin-bottom: 1em;
  line-height: 2em;
}

details.respec-tests-details > ul {
  width: 100%;
  margin-top: -0.3em;
}

details.respec-tests-details > li {
  padding-left: 1em;
}

@media print {
  .removeOnSave {
    display: none;
  }
}
</style><style>/*

github.com style (c) Vasily Polovnyov <vast@whiteants.net>

*/

.hljs {
  display: block;
  overflow-x: auto;
  padding: 0.5em;
  color: #333;
  background: #f8f8f8;
}

.hljs-comment,
.hljs-quote {
  color: #998;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-subst {
  color: #333;
  font-weight: bold;
}

.hljs-number,
.hljs-literal,
.hljs-variable,
.hljs-template-variable,
.hljs-tag .hljs-attr {
  color: #008080;
}

.hljs-string,
.hljs-doctag {
  color: #d14;
}

.hljs-title,
.hljs-section,
.hljs-selector-id {
  color: #900;
  font-weight: bold;
}

.hljs-subst {
  font-weight: normal;
}

.hljs-type,
.hljs-class .hljs-title {
  color: #458;
  font-weight: bold;
}

.hljs-tag,
.hljs-name,
.hljs-attribute {
  color: #000080;
  font-weight: normal;
}

.hljs-regexp,
.hljs-link {
  color: #009926;
}

.hljs-symbol,
.hljs-bullet {
  color: #990073;
}

.hljs-built_in,
.hljs-builtin-name {
  color: #0086b3;
}

.hljs-meta {
  color: #999;
  font-weight: bold;
}

.hljs-deletion {
  background: #fdd;
}

.hljs-addition {
  background: #dfd;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: bold;
}
</style><link rel="stylesheet" href="https://www.w3.org/StyleSheets/TR/2016/cg-final"><link rel="canonical" href="https://www.w3.org/TR/json-ld11cg-api/"><script id="initialUserConfig" type="application/json">{
  "localBiblio": {
    "JSON-LD11CG": {
      "title": "JSON-LD 1.1",
      "href": "https://www.w3.org/2018/jsonld-cg-reports/json-ld/",
      "authors": [
        "Gregg Kellogg"
      ],
      "publisher": "W3C",
      "status": "CG Final"
    },
    "JSON-LD11CG-API": {
      "title": "JSON-LD 1.1 Processing Algorithms and API",
      "href": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/",
      "authors": [
        "Gregg Kellogg"
      ],
      "publisher": "W3C",
      "status": "CG Final"
    },
    "JSON-LD11CG-FRAMING": {
      "title": "JSON-LD 1.1 Framing",
      "href": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/",
      "authors": [
        "Gregg Kellogg"
      ],
      "publisher": "W3C",
      "status": "CG Final"
    },
    "JSON-LD-TESTS": {
      "title": "JSON-LD 1.1 Test Suite",
      "href": "https://json-ld.org/test-suite/",
      "authors": [
        "Gregg Kellogg"
      ],
      "publisher": "Linking Data in JSON Community Group"
    },
    "IEEE-754-2008": {
      "title": "IEEE 754-2008 Standard for Floating-Point Arithmetic",
      "href": "http://standards.ieee.org/findstds/standard/754-2008.html",
      "publisher": "Institute of Electrical and Electronics Engineers",
      "date": "2008"
    },
    "PROMISES": {
      "title": "Promise Objects",
      "href": "https://github.com/domenic/promises-unwrapping",
      "authors": [
        "Domenic Denicola"
      ],
      "status": "unofficial",
      "date": "January 2014"
    },
    "MICROFORMATS": {
      "title": "Microformats",
      "href": "http://microformats.org"
    }
  },
  "specStatus": "CG-FINAL",
  "copyrightStart": "2010",
  "shortName": "json-ld11cg-api",
  "prevVersion": "https://www.w3.org/TR/2014/REC-json-ld-api-20140116/",
  "previousPublishDate": "2014-01-16",
  "previousMaturity": "REC",
  "edDraftURI": "https://json-ld.org/spec/latest/json-ld-api/",
  "testSuiteURI": "https://json-ld.org/test-suite/",
  "includePermalinks": true,
  "noRecTrack": true,
  "doJsonLd": true,
  "highlightVars": true,
  "testSuiteURIkey": "https://json-ld.org/test-suite/",
  "postProcess": [
    null
  ],
  "editors": [
    {
      "name": "Gregg Kellogg",
      "url": "http://greggkellogg.net/",
      "company": "Spec-Ops",
      "companyURL": "https://spec-ops.io/",
      "w3cid": "44770",
      "note": "v1.0 and v1.1"
    }
  ],
  "formerEditors": [
    {
      "name": "Markus Lanthaler",
      "url": "http://www.markus-lanthaler.com/",
      "company": "Graz University of Technology",
      "companyURL": "http://www.tugraz.at/",
      "note": "v1.0"
    },
    {
      "name": "Manu Sporny",
      "url": "http://manu.sporny.org/",
      "company": "Digital Bazaar",
      "companyURL": "https://digitalbazaar.com/",
      "note": "v1.0"
    }
  ],
  "authors": [
    {
      "name": "Dave Longley",
      "url": "https://digitalbazaar.com/",
      "company": "Digital Bazaar",
      "companyURL": "https://digitalbazaar.com/",
      "note": "v1.0"
    },
    {
      "name": "Gregg Kellogg",
      "url": "http://greggkellogg.net/",
      "company": "Spec-Ops",
      "companyURL": "https://spec-ops.io/",
      "w3cid": "44770",
      "note": "v1.0 and v1.1"
    },
    {
      "name": "Markus Lanthaler",
      "url": "http://www.markus-lanthaler.com/",
      "company": "Graz University of Technology",
      "companyURL": "http://www.tugraz.at/",
      "note": "v1.0"
    },
    {
      "name": "Manu Sporny",
      "url": "http://manu.sporny.org/",
      "company": "Digital Bazaar",
      "companyURL": "https://digitalbazaar.com/",
      "note": "v1.0"
    },
    {
      "name": "Niklas Lindström",
      "url": "http://neverspace.net/",
      "note": "v1.0"
    }
  ],
  "github": "https://github.com/json-ld/json-ld.org/",
  "wg": "JSON for Linking Data W3C Community Group",
  "wgURI": "https://www.w3.org/community/json-ld/",
  "wgPublicList": "public-linked-json",
  "maxTocLevel": 2,
  "pubDate": "2016-06-07",
  "publishISODate": "2018-06-07T00:00:00.000Z",
  "generatedSubtitle": "Final Community Group Report 07 June 2018"
}</script><meta name="description" content="This specification defines a set of algorithms for programmatic transformations
    of JSON-LD documents. Restructuring data according to the defined transformations
    often dramatically simplifies its usage. Furthermore, this document proposes
    an Application Programming Interface (API) for developers implementing the
    specified algorithms."><script type="application/ld+json">{
  "@context": [
    "http://schema.org",
    {
      "@vocab": "http://schema.org/",
      "@language": "en",
      "w3p": "http://www.w3.org/2001/02pd/rec54#",
      "foaf": "http://xmlns.com/foaf/0.1/",
      "datePublished": {
        "@type": "http://www.w3.org/2001/XMLSchema#date"
      },
      "inLanguage": {
        "@language": null
      },
      "isBasedOn": {
        "@type": "@id"
      },
      "license": {
        "@type": "@id"
      }
    }
  ],
  "id": "https://www.w3.org/TR/json-ld11cg-api/",
  "type": [
    "TechArticle"
  ],
  "name": "JSON-LD 1.1 Processing Algorithms and API",
  "inLanguage": "en",
  "license": "https://www.w3.org/Consortium/Legal/2015/copyright-software-and-document",
  "datePublished": "2018-06-07",
  "copyrightHolder": {
    "name": "World Wide Web Consortium",
    "url": "https://www.w3.org/"
  },
  "discussionUrl": "https://github.com/json-ld/json-ld.org/issues/",
  "alternativeHeadline": "",
  "isBasedOn": "https://www.w3.org/TR/2014/REC-json-ld-api-20140116/",
  "description": "This specification defines a set of algorithms for programmatic transformations\n    of JSON-LD documents. Restructuring data according to the defined transformations\n    often dramatically simplifies its usage. Furthermore, this document proposes\n    an Application Programming Interface (API) for developers implementing the\n    specified algorithms.",
  "editor": [
    {
      "type": "Person",
      "name": "Gregg Kellogg",
      "url": "http://greggkellogg.net/",
      "worksFor": {
        "name": "Spec-Ops",
        "url": "https://spec-ops.io/"
      }
    }
  ],
  "contributor": [
    {
      "type": "Person",
      "name": "Dave Longley",
      "url": "https://digitalbazaar.com/",
      "worksFor": {
        "name": "Digital Bazaar",
        "url": "https://digitalbazaar.com/"
      }
    },
    {
      "type": "Person",
      "name": "Gregg Kellogg",
      "url": "http://greggkellogg.net/",
      "worksFor": {
        "name": "Spec-Ops",
        "url": "https://spec-ops.io/"
      }
    },
    {
      "type": "Person",
      "name": "Markus Lanthaler",
      "url": "http://www.markus-lanthaler.com/",
      "worksFor": {
        "name": "Graz University of Technology",
        "url": "http://www.tugraz.at/"
      }
    },
    {
      "type": "Person",
      "name": "Manu Sporny",
      "url": "http://manu.sporny.org/",
      "worksFor": {
        "name": "Digital Bazaar",
        "url": "https://digitalbazaar.com/"
      }
    },
    {
      "type": "Person",
      "name": "Niklas Lindström",
      "url": "http://neverspace.net/"
    }
  ],
  "citation": [
    {
      "id": "https://tools.ietf.org/html/rfc7159",
      "type": "TechArticle",
      "name": "The JavaScript Object Notation (JSON) Data Interchange Format",
      "url": "https://tools.ietf.org/html/rfc7159"
    },
    {
      "id": "https://www.w3.org/2018/jsonld-cg-reports/json-ld/",
      "type": "TechArticle",
      "name": "JSON-LD 1.1",
      "url": "https://www.w3.org/2018/jsonld-cg-reports/json-ld/"
    },
    {
      "id": "https://tools.ietf.org/html/rfc3987",
      "type": "TechArticle",
      "name": "Internationalized Resource Identifiers (IRIs)",
      "url": "https://tools.ietf.org/html/rfc3987"
    },
    {
      "id": "https://tools.ietf.org/html/bcp47",
      "type": "TechArticle",
      "name": "Tags for Identifying Languages",
      "url": "https://tools.ietf.org/html/bcp47"
    },
    {
      "id": "https://www.w3.org/TR/rdf-concepts/",
      "type": "TechArticle",
      "name": "Resource Description Framework (RDF): Concepts and Abstract Syntax",
      "url": "https://www.w3.org/TR/rdf-concepts/"
    },
    {
      "id": "https://www.w3.org/TR/json-ld/",
      "type": "TechArticle",
      "name": "JSON-LD 1.0",
      "url": "https://www.w3.org/TR/json-ld/"
    },
    {
      "id": "https://tools.ietf.org/html/rfc2119",
      "type": "TechArticle",
      "name": "Key words for use in RFCs to Indicate Requirement Levels",
      "url": "https://tools.ietf.org/html/rfc2119"
    },
    {
      "id": "https://tools.ietf.org/html/rfc3986",
      "type": "TechArticle",
      "name": "Uniform Resource Identifier (URI): Generic Syntax",
      "url": "https://tools.ietf.org/html/rfc3986"
    },
    {
      "id": "https://www.w3.org/TR/xmlschema11-2/",
      "type": "TechArticle",
      "name": "W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes",
      "url": "https://www.w3.org/TR/xmlschema11-2/"
    },
    {
      "id": "https://www.w3.org/TR/rdf11-mt/",
      "type": "TechArticle",
      "name": "RDF 1.1 Semantics",
      "url": "https://www.w3.org/TR/rdf11-mt/"
    },
    {
      "id": "http://standards.ieee.org/findstds/standard/754-2008.html",
      "type": "TechArticle",
      "name": "IEEE 754-2008 Standard for Floating-Point Arithmetic",
      "url": "http://standards.ieee.org/findstds/standard/754-2008.html"
    },
    {
      "id": "https://tools.ietf.org/html/rfc5988",
      "type": "TechArticle",
      "name": "Web Linking",
      "url": "https://tools.ietf.org/html/rfc5988"
    },
    {
      "id": "https://www.w3.org/TR/json-ld-api/",
      "type": "TechArticle",
      "name": "JSON-LD 1.0 Processing Algorithms and API",
      "url": "https://www.w3.org/TR/json-ld-api/"
    },
    {
      "id": "https://json-ld.org/test-suite/",
      "type": "TechArticle",
      "name": "JSON-LD 1.1 Test Suite",
      "url": "https://json-ld.org/test-suite/"
    },
    {
      "id": "http://www.ecma-international.org/ecma-262/6.0/index.html",
      "type": "TechArticle",
      "name": "ECMA-262 6th Edition, The ECMAScript 2015 Language Specification",
      "url": "http://www.ecma-international.org/ecma-262/6.0/index.html"
    },
    {
      "id": "https://heycam.github.io/webidl/",
      "type": "TechArticle",
      "name": "Web IDL",
      "url": "https://heycam.github.io/webidl/"
    },
    {
      "id": "https://www.w3.org/TR/rdf11-concepts/",
      "type": "TechArticle",
      "name": "RDF 1.1 Concepts and Abstract Syntax",
      "url": "https://www.w3.org/TR/rdf11-concepts/"
    },
    {
      "id": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/",
      "type": "TechArticle",
      "name": "JSON-LD 1.1 Processing Algorithms and API",
      "url": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/"
    },
    {
      "id": "https://www.w3.org/TR/rdf-schema/",
      "type": "TechArticle",
      "name": "RDF Schema 1.1",
      "url": "https://www.w3.org/TR/rdf-schema/"
    },
    {
      "id": "https://www.w3.org/TR/turtle/",
      "type": "TechArticle",
      "name": "RDF 1.1 Turtle",
      "url": "https://www.w3.org/TR/turtle/"
    },
    {
      "id": "https://www.w3.org/2001/tag/doc/promises-guide",
      "type": "TechArticle",
      "name": "Writing Promise-Using Specifications",
      "url": "https://www.w3.org/2001/tag/doc/promises-guide"
    },
    {
      "id": "https://tools.ietf.org/html/rfc6839",
      "type": "TechArticle",
      "name": "Additional Media Type Structured Syntax Suffixes",
      "url": "https://tools.ietf.org/html/rfc6839"
    },
    {
      "id": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/",
      "type": "TechArticle",
      "name": "JSON-LD 1.1 Framing",
      "url": "https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/"
    }
  ]
}</script></head>

<body class="h-entry"><div class="head">
  <a href="https://www.w3.org/" class="logo">
      <img alt="W3C" width="72" height="48" src="https://www.w3.org/StyleSheets/TR/2016/logos/W3C">
  </a>
  <h1 class="title p-name" id="title">JSON-LD 1.1 Processing Algorithms and API</h1>

  <h2 id="final-community-group-report-07-june-2018">Final Community Group Report <time class="dt-published" datetime="2018-06-07">07 June 2018</time></h2>
  <dl>


    <dt>Latest editor's draft:</dt><dd><a href="https://json-ld.org/spec/latest/json-ld-api/">https://json-ld.org/spec/latest/json-ld-api/</a></dd>
    <dt>Test suite:</dt><dd><a href="https://json-ld.org/test-suite/">https://json-ld.org/test-suite/</a></dd>


    <dt>Previous version:</dt><dd><a href="https://www.w3.org/TR/2014/REC-json-ld-api-20140116/">https://www.w3.org/TR/2014/REC-json-ld-api-20140116/</a></dd>

    <dt>Editor:</dt>
    <dd class="p-author h-card vcard" data-editor-id="44770"><a class="u-url url p-name fn" href="http://greggkellogg.net/">Gregg Kellogg</a> (<a class="p-org org h-org h-card" href="https://spec-ops.io/">Spec-Ops</a>) (v1.0 and v1.1)</dd>
    <dt>Former editors:</dt><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a> (<a class="p-org org h-org h-card" href="http://www.tugraz.at/">Graz University of Technology</a>) (v1.0)</dd><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="http://manu.sporny.org/">Manu Sporny</a> (<a class="p-org org h-org h-card" href="https://digitalbazaar.com/">Digital Bazaar</a>) (v1.0)</dd>
    <dt>Authors:</dt><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="https://digitalbazaar.com/">Dave Longley</a> (<a class="p-org org h-org h-card" href="https://digitalbazaar.com/">Digital Bazaar</a>) (v1.0)</dd><dd class="p-author h-card vcard" data-editor-id="44770"><a class="u-url url p-name fn" href="http://greggkellogg.net/">Gregg Kellogg</a> (<a class="p-org org h-org h-card" href="https://spec-ops.io/">Spec-Ops</a>) (v1.0 and v1.1)</dd><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="http://www.markus-lanthaler.com/">Markus Lanthaler</a> (<a class="p-org org h-org h-card" href="http://www.tugraz.at/">Graz University of Technology</a>) (v1.0)</dd><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="http://manu.sporny.org/">Manu Sporny</a> (<a class="p-org org h-org h-card" href="https://digitalbazaar.com/">Digital Bazaar</a>) (v1.0)</dd><dd class="p-author h-card vcard"><a class="u-url url p-name fn" href="http://neverspace.net/">Niklas Lindström</a> (v1.0)</dd>
    <dt>Participate:</dt><dd>
      <a href="https://github.com/json-ld/json-ld.org/">GitHub json-ld/json-ld.org</a>
    </dd><dd>
      <a href="https://github.com/json-ld/json-ld.org/issues/">File a bug</a>
    </dd><dd>
      <a href="https://github.com/json-ld/json-ld.org/commits/gh-pages">Commit history</a>
    </dd><dd>
      <a href="https://github.com/json-ld/json-ld.org/pulls/">Pull requests</a>
    </dd>
  </dl>

  <p class="copyright">
    <a href="https://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
    2010-2018
    the Contributors to the JSON-LD 1.1 Processing Algorithms and API Specification, published by the
    <a href="https://www.w3.org/community/json-ld/">JSON for Linking Data W3C Community Group</a> under the
    <a href="https://www.w3.org/community/about/agreements/fsa/">W3C Community Final Specification Agreement (FSA)</a>.
      A human-readable <a href="https://www.w3.org/community/about/agreements/fsa-deed/">summary</a> is available.

  </p>
  <hr title="Separator for header">
</div>
<section id="abstract" class="introductory"><h2 id="abstract-0">Abstract</h2>
  <p>This specification defines a set of algorithms for programmatic transformations
    of JSON-LD documents. Restructuring data according to the defined transformations
    often dramatically simplifies its usage. Furthermore, this document proposes
    an Application Programming Interface (API) for developers implementing the
    specified algorithms.</p>
</section>

<section id="sotd" class="introductory"><h2 id="status-of-this-document">Status of This Document</h2><p>
  This specification was published by the <a href="https://www.w3.org/community/json-ld/">JSON for Linking Data W3C Community Group</a>.
  It is not a W3C Standard nor is it on the W3C Standards Track.

    Please note that under the
    <a href="https://www.w3.org/community/about/agreements/final/">W3C Community Final Specification Agreement (FSA)</a>
    other conditions apply.

  Learn more about
  <a href="https://www.w3.org/community/">W3C Community and Business Groups</a>.
</p><p>This document has been developed by the
    <a href="https://www.w3.org/community/json-ld/">JSON for Linking Data W3C Community Group</a>
    as an update to the 1.0 recommendation [<cite><a class="bibref" href="#bib-JSON-LD-API">JSON-LD-API</a></cite>] developed
    by the <a href="https://www.w3.org/2011/rdf-wg/wiki/Main_Page">RDF Working Group</a>.
    The specification has undergone
    significant development, review, and changes during the course of several years.</p><p>There are several independent
    <a href="https://json-ld.org/test-suite/reports/">interoperable implementations</a> of
    this specification, a test suite [<cite><a class="bibref" href="#bib-JSON-LD-TESTS">JSON-LD-TESTS</a></cite>] and a
    <a href="https://json-ld.org/playground/">live JSON-LD playground</a> that is capable
    of demonstrating the features described in this document.</p><p>If you wish to make comments regarding this document, please send them to
    <a href="mailto:public-linked-json@w3.org">public-linked-json@w3.org</a>
    (<a href="mailto:public-linked-json-request@w3.org?subject=subscribe">subscribe</a>,
    <a href="https://lists.w3.org/Archives/Public/public-linked-json/">archives</a>).</p><section>
    <h3 id="set-of-documents">Set of Documents</h3>
    <p>This document is one of three JSON-LD 1.1 Recommendations produced by the
      <a href="https://www.w3.org/community/json-ld/">JSON for Linking Data W3C Community Group</a>:</p>

    <ul>
      <li><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/">JSON-LD 1.1</a></li>
      <li><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/">JSON-LD 1.1 Processing Algorithms and API</a></li>
      <li><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/">JSON-LD 1.1 Framing</a></li>
    </ul>
  </section></section><nav id="toc"><h2 class="introductory" id="table-of-contents">Table of Contents</h2><ol class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a><ol class="toc"><li class="tocline"><a href="#contributing" class="tocxref"><span class="secno">1.1 </span>Contributing</a></li><li class="tocline"><a href="#terminology" class="tocxref"><span class="secno">1.2 </span>Terminology</a><ol class="toc"></ol></li><li class="tocline"><a href="#typographical-conventions" class="tocxref"><span class="secno">1.3 </span>Typographical conventions</a></li><li class="tocline"><a href="#example-conventions" class="tocxref"><span class="secno">1.4 </span>Example Conventions</a></li></ol></li><li class="tocline"><a href="#features" class="tocxref"><span class="secno">2. </span>Features</a><ol class="toc"><li class="tocline"><a href="#expansion" class="tocxref"><span class="secno">2.1 </span>Expansion</a></li><li class="tocline"><a href="#compaction" class="tocxref"><span class="secno">2.2 </span>Compaction</a></li><li class="tocline"><a href="#flattening" class="tocxref"><span class="secno">2.3 </span>Flattening</a></li><li class="tocline"><a href="#rdf-serialization-deserialization" class="tocxref"><span class="secno">2.4 </span>RDF Serialization/Deserialization</a></li></ol></li><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">3. </span>Conformance</a></li><li class="tocline"><a href="#context-processing-algorithms" class="tocxref"><span class="secno">4. </span>Context Processing Algorithms</a><ol class="toc"><li class="tocline"><a href="#context-processing-algorithm" class="tocxref"><span class="secno">4.1 </span>Context Processing Algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#create-term-definition" class="tocxref"><span class="secno">4.2 </span>Create Term Definition</a><ol class="toc"></ol></li><li class="tocline"><a href="#iri-expansion" class="tocxref"><span class="secno">4.3 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion</a><ol class="toc"></ol></li></ol></li><li class="tocline"><a href="#expansion-algorithms" class="tocxref"><span class="secno">5. </span>Expansion Algorithms</a><ol class="toc"><li class="tocline"><a href="#expansion-algorithm" class="tocxref"><span class="secno">5.1 </span>Expansion Algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#value-expansion" class="tocxref"><span class="secno">5.2 </span>Value Expansion</a><ol class="toc"></ol></li></ol></li><li class="tocline"><a href="#compaction-algorithms" class="tocxref"><span class="secno">6. </span>Compaction Algorithms</a><ol class="toc"><li class="tocline"><a href="#compaction-algorithm" class="tocxref"><span class="secno">6.1 </span>Compaction Algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#inverse-context-creation" class="tocxref"><span class="secno">6.2 </span>Inverse Context Creation</a><ol class="toc"></ol></li><li class="tocline"><a href="#iri-compaction" class="tocxref"><span class="secno">6.3 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction</a><ol class="toc"></ol></li><li class="tocline"><a href="#term-selection" class="tocxref"><span class="secno">6.4 </span>Term Selection</a><ol class="toc"></ol></li><li class="tocline"><a href="#value-compaction" class="tocxref"><span class="secno">6.5 </span>Value Compaction</a><ol class="toc"></ol></li></ol></li><li class="tocline"><a href="#flattening-algorithms" class="tocxref"><span class="secno">7. </span>Flattening Algorithms</a><ol class="toc"><li class="tocline"><a href="#flattening-algorithm" class="tocxref"><span class="secno">7.1 </span>Flattening Algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#node-map-generation" class="tocxref"><span class="secno">7.2 </span>Node Map Generation</a><ol class="toc"></ol></li><li class="tocline"><a href="#generate-blank-node-identifier" class="tocxref"><span class="secno">7.3 </span>Generate Blank Node Identifier</a><ol class="toc"></ol></li><li class="tocline"><a href="#merge-node-maps" class="tocxref"><span class="secno">7.4 </span>Merge Node Maps</a></li></ol></li><li class="tocline"><a href="#rdf-serialization-deserialization-algorithms" class="tocxref"><span class="secno">8. </span>RDF Serialization/Deserialization Algorithms</a><ol class="toc"><li class="tocline"><a href="#deserialize-json-ld-to-rdf-algorithm" class="tocxref"><span class="secno">8.1 </span>Deserialize JSON-LD to RDF algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#object-to-rdf-conversion" class="tocxref"><span class="secno">8.2 </span>Object to RDF Conversion</a><ol class="toc"></ol></li><li class="tocline"><a href="#list-to-rdf-conversion" class="tocxref"><span class="secno">8.3 </span>List to RDF Conversion</a><ol class="toc"></ol></li><li class="tocline"><a href="#serialize-rdf-as-json-ld-algorithm" class="tocxref"><span class="secno">8.4 </span>Serialize RDF as JSON-LD Algorithm</a><ol class="toc"></ol></li><li class="tocline"><a href="#rdf-to-object-conversion" class="tocxref"><span class="secno">8.5 </span>RDF to Object Conversion</a><ol class="toc"></ol></li><li class="tocline"><a href="#data-round-tripping" class="tocxref"><span class="secno">8.6 </span>Data Round Tripping</a></li></ol></li><li class="tocline"><a href="#the-application-programming-interface" class="tocxref"><span class="secno">9. </span>The Application Programming Interface</a><ol class="toc"><li class="tocline"><a href="#the-jsonldprocessor-interface" class="tocxref"><span class="secno">9.1 </span>The <span data-dfn-type="dfn" data-idl="" data-title="JsonLdProcessor" data-dfn-for=""><code>JsonLdProcessor</code></span> Interface</a></li><li class="tocline"><a href="#the-jsonldoptions-type" class="tocxref"><span class="secno">9.2 </span>The JsonLdOptions Type</a></li><li class="tocline"><a href="#remote-document-and-context-retrieval" class="tocxref"><span class="secno">9.3 </span>Remote Document and Context Retrieval</a><ol class="toc"></ol></li><li class="tocline"><a href="#error-handling" class="tocxref"><span class="secno">9.4 </span>Error Handling</a><ol class="toc"></ol></li></ol></li><li class="tocline"><a href="#idl-index" class="tocxref"><span class="secno">A. </span>IDL Index</a></li><li class="tocline"><a href="#security" class="tocxref"><span class="secno">B. </span>Security Considerations</a></li><li class="tocline"><a href="#changes-since-1-0-recommendation-of-16-january-2014" class="tocxref"><span class="secno">C. </span>Changes since 1.0 Recommendation of 16 January 2014</a></li><li class="tocline"><a href="#open-issues" class="tocxref"><span class="secno">D. </span>Open Issues</a></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">E. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">F. </span>References</a><ol class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">F.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">F.2 </span>Informative references</a></li></ol></li></ol></nav>


<section class="informative" id="introduction">
  <!--OddPage--><h2 id="x1-introduction"><span class="secno">1. </span>Introduction&nbsp;<span class="permalink"><a href="#introduction" aria-label="Permalink for 1. Introduction" title="Permalink for 1. Introduction"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>

  <p>This document is a detailed specification of the JSON-LD processing algorithms.
    The document is primarily intended for the following audiences:</p>

  <ul>
    <li>Software developers who want to implement the algorithms to transform
      JSON-LD documents.</li>
    <li>Web authors and developers who want a very detailed view of how
      a <a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processor</a> operates.</li>
    <li>Developers who want an overview of the proposed JSON-LD API.</li>
  </ul>

  <p>To understand the basics in this specification you must first be familiar with
    <a href="https://tools.ietf.org/html/rfc7159">JSON</a>, which is detailed in [<cite><a class="bibref" href="#bib-RFC7159">RFC7159</a></cite>]. You must also understand the
    <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/">JSON-LD syntax</a> defined in the JSON-LD 1.1 Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>], which is the base syntax used by all
    of the algorithms in this document. To understand the API and how it is
    intended to operate in a programming environment, it is useful to have working
    knowledge of the JavaScript programming language [<cite><a class="bibref" href="#bib-ECMASCRIPT-6.0">ECMASCRIPT-6.0</a></cite>] and
    WebIDL [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]. To understand how JSON-LD maps to RDF, it is helpful to be
    familiar with the basic RDF concepts [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</p>

  <section id="contributing">
    <h3 id="x1-1-contributing"><span class="secno">1.1 </span>Contributing&nbsp;<span class="permalink"><a href="#contributing" aria-label="Permalink for 1.1 Contributing" title="Permalink for 1.1 Contributing"><span>§</span></a></span></h3>

    <p>There are a number of ways that one may participate in the development of
      this specification:</p>

    <ul>
      <li>Technical discussion typically occurs on the public mailing list:
        <a href="https://lists.w3.org/Archives/Public/public-linked-json/">public-linked-json@w3.org</a></li>

      <!--<li><a href="https://json-ld.org/minutes/">Public teleconferences</a> are held
        on Tuesdays at 1500UTC on the second and fourth week of each month.</li> -->

      <li>The <a href="https://webchat.freenode.net/?channels=json-ld">#json-ld</a>
        IRC channel is available for real-time discussion on irc.freenode.net.</li>
    </ul>

  </section>

  <section id="terminology">
    <h3 id="x1-2-terminology"><span class="secno">1.2 </span>Terminology&nbsp;<span class="permalink"><a href="#terminology" aria-label="Permalink for 1.2 Terminology" title="Permalink for 1.2 Terminology"><span>§</span></a></span></h3>

    <p>This document uses the following terms as defined in JSON [<cite><a class="bibref" href="#bib-RFC7159">RFC7159</a></cite>]. Refer
      to the <a href="https://tools.ietf.org/html/rfc7159#section-2">JSON Grammar section</a> in [<cite><a class="bibref" href="#bib-RFC7159">RFC7159</a></cite>] for formal definitions.</p>

    <div data-oninclude="restrictReferences"><dl class="termlist" data-sort="" id="terms"><dt><dfn data-lt="arrays|array" id="dfn-arrays" data-dfn-type="dfn">array</dfn></dt><dd>
    In the JSON serialization, an array structure is represented as square brackets surrounding zero
    or more values. Values are separated by commas.
    In the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>, an array is an <em>ordered</em> collection of zero or more values.
    While JSON-LD uses the same array representation as JSON,
    the collection is <em>unordered</em> by default. While order is
    preserved in regular JSON arrays, it is not in regular JSON-LD arrays
    unless specifically defined (see
    <a class="externalDFN" href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/#sets-and-lists">Sets and Lists</a> in
    the JSON-LD Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>]).</dd>
  <dt><dfn data-lt="json objects|json object" id="dfn-json-objects" data-dfn-type="dfn">JSON object</dfn></dt><dd>
    In the JSON serialization, an <a class="externalDFN" href="https://tools.ietf.org/html/rfc7159#section-4">object</a> structure is represented as a pair of curly brackets surrounding zero or
    more key-value pairs. A key is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>. A single colon comes after
    each key, separating the key from the value. A single comma separates a value
    from a following key. In JSON-LD the keys in an object <em class="rfc2119" title="MUST">MUST</em> be unique.
    In the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a> a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> is equivalent to a
    <dfn data-lt="dictionaries|dictionary" class="preserve" data-dfn-type="dfn" id="dfn-dictionaries"><a href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a></dfn> (see [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]).</dd>
  <dt class="changed"><dfn data-lt="internal representation|json-ld internal representation" id="dfn-internal-representation" data-dfn-type="dfn">JSON-LD internal representation</dfn></dt><dd class="changed">The JSON-LD
    internal representation is the result of transforming a JSON syntactic structure
    into the core data structures suitable for direct processing:
    <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>,
    <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>, <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#idl-boolean">booleans</a>, and <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a>.</dd>
  <dt><dfn id="dfn-null" data-dfn-type="dfn">null</dfn></dt><dd>
    The use of the <a class="externalDFN" href="https://tools.ietf.org/html/rfc7159#section-3">null</a> value within JSON-LD is used to
    ignore or reset values. A key-value pair in the <code>@context</code> where
    the value, or the <code>@id</code> of the value, is <code>null</code>
    explicitly decouples a term's association with an <abbr title="Internationalized Resource Identifier">IRI</abbr>. A key-value pair in
    the body of a <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> whose value is <code>null</code> has the
    same meaning as if the key-value pair was not defined. If
    <code>@value</code>, <code>@list</code>, or <code>@set</code> is set to
    <code>null</code> in expanded form, then the entire <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON
    object</a> is ignored.</dd>
  <dt><dfn data-lt="numbers|json number|json numbers|number" id="dfn-numbers" data-dfn-type="dfn">number</dfn></dt><dd>
    In the JSON serialization, a <a class="externalDFN" href="https://tools.ietf.org/html/rfc7159#section-6">number</a> is similar to that used in most programming languages, except
    that the octal and hexadecimal formats are not used and that leading
    zeros are not allowed.
    In the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>, a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> is equivalent to either
    a <dfn class="preserve" data-dfn-type="dfn" id="dfn-long"><a href="https://heycam.github.io/webidl/#idl-long">long</a></dfn>
    or <dfn class="preserve" data-dfn-type="dfn" id="dfn-double"><a href="https://heycam.github.io/webidl/#idl-double">double</a></dfn>, depending
    on if the number has a non-zero fractional part (see [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]).</dd>
  <dt><dfn id="dfn-scalar" data-dfn-type="dfn">scalar</dfn></dt><dd>
    A scalar is either a JSON <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>, <a href="#dfn-true" class="internalDFN" data-link-type="dfn">true</a>,
    or <a href="#dfn-false" class="internalDFN" data-link-type="dfn">false</a>.</dd>
  <dt><dfn data-lt="strings|string" id="dfn-strings" data-dfn-type="dfn">string</dfn></dt><dd>
    A <a class="externalDFN" href="https://tools.ietf.org/html/rfc7159#section-7">string</a> is a sequence of zero or more Unicode (UTF-8) characters,
    wrapped in double quotes, using backslash escapes (if necessary). A
    character is represented as a single character string.</dd>
  <dt><dfn id="dfn-true" data-dfn-type="dfn">true</dfn> and <dfn id="dfn-false" data-dfn-type="dfn">false</dfn></dt><dd>
    <a class="externalDFN" href="https://tools.ietf.org/html/rfc7159#section-3">Values</a> that are used to express one of two possible
    <dfn data-lt="booleans|boolean" class="preserve" data-dfn-type="dfn" id="dfn-booleans"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></dfn> states.</dd></dl>

<p>Furthermore, the following terminology is used throughout this document:</p>

<dl class="termlist" data-sort=""><dt><dfn data-lt="absolute iris|absolute iri" id="dfn-absolute-iris" data-dfn-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    An <a class="externalDFN" href="https://tools.ietf.org/html/rfc3987#section-1.3">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is defined in [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>] containing a <em>scheme</em> along with a <em>path</em> and
    optional <em>query</em> and fragment segments.</dd>
  <dt><dfn id="dfn-active-context" data-dfn-type="dfn">active context</dfn></dt><dd>
    A <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> that is used to resolve <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> while the processing
    algorithm is running.</dd>
  <dt><dfn data-lt="base iris|base iri" id="dfn-base-iris" data-dfn-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    The <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> established in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>,
    or is based on the <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> location. The <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is used to turn
    <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative IRIs</a> into <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute IRIs</a>.</dd>
  <dt><dfn data-lt="blank nodes|blank node" id="dfn-blank-nodes" data-dfn-type="dfn">blank node</dfn></dt><dd>
    A <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">graph</a> that is neither an
    <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, nor a <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD value</a>, nor a <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a>.
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node">blank node</a> does not contain a de-referenceable
    identifier because it is either ephemeral in nature or does not contain information that needs to be
    linked to from outside of the <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a>. A blank node is assigned an identifier starting with
    the prefix <code>_:</code>.</dd>
  <dt><dfn data-lt="blank node identifiers|blank node identifier" id="dfn-blank-node-identifiers" data-dfn-type="dfn">blank node identifier</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-blank-node-identifier">blank node identifier</a> is a string that can be used as an identifier for a
    <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a> within the scope of a JSON-LD document. Blank node identifiers
    begin with <code>_:</code>.</dd>
  <dt><dfn data-lt="compact iris|compact iri" id="dfn-compact-iris" data-dfn-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    A compact <abbr title="Internationalized Resource Identifier">IRI</abbr> is has the form of <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a>:<em>suffix</em> and is used as a way
    of expressing an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> without needing to define separate <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> definitions for
    each <abbr title="Internationalized Resource Identifier">IRI</abbr> contained within a common vocabulary identified by <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a>.</dd>
  <dt><dfn data-lt="contexts|context" id="dfn-contexts" data-dfn-type="dfn">context</dfn></dt><dd>
    A a set of rules for interpreting a <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> as specified in
    <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/#the-context">The Context</a> of the JSON-LD Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>].</dd>
  <dt><dfn id="dfn-datatype-iri" data-dfn-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
    as specified by [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
  <dt><dfn id="dfn-default-graph" data-dfn-type="dfn">default graph</dfn></dt><dd>
    The <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-default-graph">default graph</a> is the only graph in a JSON-LD document which has no <a href="#dfn-graph-names" class="internalDFN" data-link-type="dfn">graph name</a>.
    When executing an algorithm, the graph where data should be placed
    if a <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graph</a> is not specified.</dd>
  <dt><dfn id="dfn-default-language" data-dfn-type="dfn">default language</dfn></dt><dd>
    The default language is set in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> using the <code>@language</code> key whose
    value <em class="rfc2119" title="MUST">MUST</em> be a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> representing a [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>] language code or <code>null</code>.</dd>
  <dt></dt>
  <dt><dfn data-lt="edges|edge" id="dfn-edges" data-dfn-type="dfn">edge</dfn></dt><dd>
    Every <a href="#dfn-edges" class="internalDFN" data-link-type="dfn">edge</a> has a direction associated with it and is labeled with
    an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>. Within the JSON-LD syntax
    these edge labels are called <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a>. Whenever possible, an
    <a href="#dfn-edges" class="internalDFN" data-link-type="dfn">edge</a> should be labeled with an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
  <dt><dfn data-lt="expanded term definitions|expanded term definition" id="dfn-expanded-term-definitions" data-dfn-type="dfn">expanded term definition</dfn></dt><dd>
    An expanded term definition, is a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> where the value is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a>
    containing one or more <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a> to define the associated <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
    if this is a reverse property, the type associated with string values, and a container mapping.</dd>
  <dt><dfn data-lt="json-ld frame|frames|frame" id="dfn-json-ld-frame" data-dfn-type="dfn">Frame</dfn></dt><dd>
    A <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a>, which describes the form for transforming
    another <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> using matching and embedding rules.
    A frame document allows additional keywords and certain property values
    to describe the matching and transforming process.</dd>
  <dt></dt>
  <dt><dfn data-lt="graph names|graph name" id="dfn-graph-names" data-dfn-type="dfn">graph name</dfn></dt><dd>
    The <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> identifying a <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-graph-name">named graph</a>.</dd>
  <dt class="changed"><dfn data-lt="graph objects|graph object" id="dfn-graph-objects" data-dfn-type="dfn">graph object</dfn></dt><dd class="changed">
    A <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a> represents a <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graph</a> represented as the
    value of a <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a> within a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>. When expanded, a
    graph object <em class="rfc2119" title="MUST">MUST</em> have an <code>@graph</code> member, and may also have
    <code>@id</code>, and <code>@index</code> members.
    A <dfn class="preserve" data-lt="simple graph objects|simple graph object" data-dfn-type="dfn" id="dfn-simple-graph-objects">simple graph object</dfn> is a
    <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a> which does not have an <code>@id</code> member. Note
    that <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a> may have a <code>@graph</code> member, but are
    not considered <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph objects</a> if they include any other properties.
    A top-level object consisting of <code>@graph</code> is also not a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>.</dd>
 <dt class="changed"><dfn data-lt="id maps|id map" id="dfn-id-maps" data-dfn-type="dfn">id map</dfn></dt><dd class="changed">
    An <a href="#dfn-id-maps" class="internalDFN" data-link-type="dfn">id map</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> value of a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> defined with
    <code>@container</code> set to <code>@id</code>, who's keys are
    interpreted as <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> representing the <code>@id</code>
    of the associated <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>; value <em class="rfc2119" title="MUST">MUST</em> be a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>.
    If the value contains a property expanding to <code>@id</code>, it's value <em class="rfc2119" title="MUST">MUST</em>
    be equivalent to the referencing key.</dd>
  <dt></dt>
  <dt><dfn data-lt="index maps|index map" id="dfn-index-maps" data-dfn-type="dfn">index map</dfn></dt><dd>
  An <a href="#dfn-index-maps" class="internalDFN" data-link-type="dfn">index map</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> value of a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> defined with
  <code>@container</code> set to <code>@index</code>, whose values <em class="rfc2119" title="MUST">MUST</em> be any of the following types:
    <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,
    <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>,
    <a href="#dfn-true" class="internalDFN" data-link-type="dfn">true</a>,
    <a href="#dfn-false" class="internalDFN" data-link-type="dfn">false</a>,
    <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a>,
    <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>,
    <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>,
    <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>,
    <a href="#dfn-set-object" class="internalDFN" data-link-type="dfn">set object</a>, or
    an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of zero or more of the above possibilities.
  </dd>
  <dt><dfn data-lt="iris|internationalized resource identifier|iri" id="dfn-iris" data-dfn-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    An <a class="externalDFN" href="https://tools.ietf.org/html/rfc3987#section-1.3">Internationalized Resource Identifier</a> as described in [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>].</dd>
  <dt><dfn data-lt="json-ld documents|json-ld document" id="dfn-json-ld-documents" data-dfn-type="dfn">JSON-LD document</dfn></dt><dd>
    A <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> is a serialization of a collection of
    <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">graphs</a> and comprises exactly one
    <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a> and zero or more <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graphs</a>.</dd>
  <dt><dfn data-lt="json-ld processors|processors|json-ld processor" id="dfn-json-ld-processors" data-dfn-type="dfn">JSON-LD Processor</dfn></dt><dd>
    A <a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processor</a> is a system which can perform the algorithms defined in [<cite><a class="bibref" href="#bib-JSON-LD11CG-API">JSON-LD11CG-API</a></cite>].</dd>
  <dt><dfn data-lt="json-ld values|json-ld value" id="dfn-json-ld-values" data-dfn-type="dfn">JSON-LD value</dfn></dt><dd>
    A <a data-lt="JSON-LD values" href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD value</a> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>,
    <a href="#dfn-true" class="internalDFN" data-link-type="dfn">true</a> or <a href="#dfn-false" class="internalDFN" data-link-type="dfn">false</a>, a <a href="#dfn-typed-values" class="internalDFN" data-link-type="dfn">typed value</a>, or a
    <a href="#dfn-language-tagged-strings" class="internalDFN" data-link-type="dfn">language-tagged string</a>.</dd>
  <dt><dfn data-lt="keywords|keyword" id="dfn-keywords" data-dfn-type="dfn">keyword</dfn></dt><dd>
    A JSON key that is specific to JSON-LD, specified in the JSON-LD Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>]
    in the section titled <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/#syntax-tokens-and-keywords">Syntax Tokens and Keywords</a>.</dd>
  <dt><dfn data-lt="language maps|language map" id="dfn-language-maps" data-dfn-type="dfn">language map</dfn></dt><dd>
    An <a href="#dfn-language-maps" class="internalDFN" data-link-type="dfn">language map</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> value of a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> defined with
    <code>@container</code> set to <code>@language</code>, whose keys <em class="rfc2119" title="MUST">MUST</em> be <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a> representing
    [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>] language codes and the values <em class="rfc2119" title="MUST">MUST</em> be any of the following types:
      <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a>,
      <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, or
      an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of zero or more of the above possibilities.
    </dd>
  <dt><dfn data-lt="language-tagged strings|language-tagged string" id="dfn-language-tagged-strings" data-dfn-type="dfn">language-tagged string</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-language-tagged-string">language-tagged string</a> consists of a string and a non-empty language
    tag as defined by [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>]. The <dfn id="dfn-language-tag" data-dfn-type="dfn">language tag</dfn> <em class="rfc2119" title="MUST">MUST</em> be well-formed according to
    <a href="https://tools.ietf.org/html/bcp47#section-2.2.9">section 2.2.9 Classes of Conformance</a>
    of [<cite><a class="bibref" href="#bib-BCP47">BCP47</a></cite>], and is normalized to lowercase.</dd>
  <dt></dt>
  <dt><dfn data-lt="graph|graphs|linked data graph" id="dfn-graph" data-dfn-type="dfn">linked data graph</dfn></dt><dd>
    A labeled directed <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-graph">graph</a>, i.e., a set of <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">nodes</a>
    connected by <a href="#dfn-edges" class="internalDFN" data-link-type="dfn">edges</a>,
    as specified in the <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/#data-model">Data Model</a>
    section of the JSON-LD specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>].
    A <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a> is a generalized representation of an
    <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-graph">RDF graph</a>
    as defined in [<cite><a class="bibref" href="#bib-RDF-CONCEPTS">RDF-CONCEPTS</a></cite>].</dd>
  <dt><dfn data-lt="lists|list" id="dfn-lists" data-dfn-type="dfn">list</dfn></dt><dd>
    A <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a> is an ordered sequence of <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a>,
    <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank nodes</a>, and <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a>.
    See <dfn data-lt="collection|rdf collection" class="preserve" data-dfn-type="dfn" id="dfn-collection"><a href="https://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a></dfn>
    in [<cite><a class="bibref" href="#bib-RDF-SCHEMA">RDF-SCHEMA</a></cite>].</dd>
  <dt><dfn data-lt="list objects|list object" id="dfn-list-objects" data-dfn-type="dfn">list object</dfn></dt><dd>
    A <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> that has an <code>@list</code>
    member.</dd>
  <dt></dt>
  <dt><dfn data-lt="local contexts|local context" id="dfn-local-contexts" data-dfn-type="dfn">local context</dfn></dt><dd>
    A <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> that is specified within a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a>,
    specified via the <code>@context</code> <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>.</dd>
  <dt><dfn data-lt="named graphs|named graph" id="dfn-named-graphs" data-dfn-type="dfn">named graph</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-named-graph">named graph</a> is a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a> that is identified by an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a>.</dd>
  <dt></dt>
  <dt><dfn data-lt="nodes|node" id="dfn-nodes" data-dfn-type="dfn">node</dfn></dt><dd>
    Every <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-node">node</a> is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, a <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a>,
    a <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD value</a>, or a <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a>.
    A piece of information that is represented in a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a>.</dd>
  <dt><dfn data-lt="node objects|node object" id="dfn-node-objects" data-dfn-type="dfn">node object</dfn></dt><dd>
    A <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> represents zero or more <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a> of a
    <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in the <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">graph</a> serialized by the
    <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a>. A <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> is a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>
    if it exists outside of the JSON-LD <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> and:
    <ul>
      <li>it does not contain the <code>@value</code>, <code>@list</code>,
        or <code>@set</code> keywords, or</li>
      <li>it is not the top-most <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> in the JSON-LD document consisting
        of no other members than <code>@graph</code> and <code>@context</code>.</li>
    </ul>
  </dd>
  <dt></dt>
  <dt><dfn data-lt="objects|object" id="dfn-objects" data-dfn-type="dfn">object</dfn></dt><dd>
    An <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-object">object</a> is a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a> with at least one incoming edge.
    See <dfn class="preserve" data-dfn-type="dfn" id="dfn-rdf-object"><a href="https://www.w3.org/TR/rdf11-concepts/#dfn-object">RDF object</a></dfn>in [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
  <dt><dfn data-lt="prefixes|prefix" id="dfn-prefixes" data-dfn-type="dfn">prefix</dfn></dt><dd>
    A <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> is the first component of a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> which comes from a
    <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that maps to a string that, when prepended to the suffix of the <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
    results in an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
  <dt><dfn id="dfn-processing-mode" data-dfn-type="dfn">processing mode</dfn></dt><dd>
    The processing mode defines how a JSON-LD document is processed.
    By default, all documents are assumed to be conformant with
    <a href="https://www.w3.org/TR/json-ld/">JSON-LD 1.0</a> [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>]. By defining
    a different version using the <code>@version</code> member in a
    <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>, or via explicit API option, other processing modes
    can be accessed. This specification defines extensions for the
    <code>json-ld-1.1</code> <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>.</dd>
  <dt><dfn data-lt="properties|property" id="dfn-properties" data-dfn-type="dfn">property</dfn></dt><dd>
    The <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> label of an edge in a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a>.
    See <dfn data-lt="predicate|predicates|rdf predicates|rdf predicate" class="preserve" data-dfn-type="dfn" id="dfn-predicate"><a href="https://www.w3.org/TR/rdf11-concepts/#dfn-predicate">RDF predicate</a></dfn> in [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
    <dt></dt>
  <dt><dfn data-lt="dataset|rdf dataset" id="dfn-dataset" data-dfn-type="dfn">RDF dataset</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-dataset">dataset</a> as specified by [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>] representing a collection of
    <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-graph">RDF graphs</a>.</dd>
  <dt><dfn data-lt="resource|rdf resource" id="dfn-resource" data-dfn-type="dfn">RDF resource</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-resource">resource</a> as specified by [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
  <dt><dfn data-lt="triple|triples|rdf triples|rdf triple" id="dfn-triple" data-dfn-type="dfn">RDF triple</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-rdf-triple">triple</a> as specified by [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
  <dt><dfn data-lt="relative iris|relative iri" id="dfn-relative-iris" data-dfn-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></dfn></dt><dd>
    A relative <abbr title="Internationalized Resource Identifier">IRI</abbr> is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> that is relative to some other <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
    typically the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> of the document. Note that
    <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a>, values of <code>@type</code>, and values of <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> defined to be <em>vocabulary relative</em>
    are resolved relative to the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, not the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
  <dt><dfn id="dfn-set-object" data-dfn-type="dfn">set object</dfn></dt><dd>
    A <a href="#dfn-set-object" class="internalDFN" data-link-type="dfn">set object</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> that has an <code>@set</code>
    member.</dd>
  <dt><dfn data-lt="subjects|subject" id="dfn-subjects" data-dfn-type="dfn">subject</dfn></dt><dd>
    A <a class="externalDFN" href="https://www.w3.org/TR/rdf11-concepts/#dfn-subject">subject</a> is a<a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in a <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">linked data graph</a> with at least one outgoing edge, related to an <a href="#dfn-objects" class="internalDFN" data-link-type="dfn">object</a> node through a <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a>.
    See <dfn class="preserve" data-dfn-type="dfn" id="dfn-rdf-subject"><a href="https://www.w3.org/TR/rdf11-concepts/#dfn-subject">RDF subject</a></dfn> in [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>].</dd>
    <dt><dfn data-lt="terms|term" id="dfn-terms" data-dfn-type="dfn">term</dfn></dt><dd>
    A <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> is a short word defined in a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> that <em class="rfc2119" title="MAY">MAY</em> be expanded to an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>
  </dd>
  <dt><dfn data-lt="term definitions|term definition" id="dfn-term-definitions" data-dfn-type="dfn">term definition</dfn></dt><dd>
    A term definition is an entry in a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>, where the key defines a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> which may be used within
    a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> as a <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a>, type, or elsewhere that a string is interpreted as a vocabulary item.
    Its value is either a string (<dfn data-lt="simple terms|simple term|simple term definitions|simple term definition" id="dfn-simple-terms" data-dfn-type="dfn">simple term definition</dfn>), expanding to an absolute <abbr title="Internationalized Resource Identifier">IRI</abbr>, or an <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a>.
  </dd>
  <dt class="changed"><dfn data-lt="type maps|type map" id="dfn-type-maps" data-dfn-type="dfn">type map</dfn></dt><dd class="changed">
    An <a href="#dfn-type-maps" class="internalDFN" data-link-type="dfn">type map</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> value of a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> defined with
    <code>@container</code> set to <code>@type</code>, who's keys are
    interpreted as <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> representing the <code>@type</code>
    of the associated <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>;
    value <em class="rfc2119" title="MUST">MUST</em> be a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>, or <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of node objects.
    If the value contains a property expanding to <code>@type</code>, it's values
    are merged with the map value when expanding.</dd>
  <dt></dt>
  <dt><dfn data-lt="typed values|typed value" id="dfn-typed-values" data-dfn-type="dfn">typed value</dfn></dt><dd>
    A <a href="#dfn-typed-values" class="internalDFN" data-link-type="dfn">typed value</a> consists of a value, which is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, and a type,
    which is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
  <dt><dfn data-lt="value objects|value object" id="dfn-value-objects" data-dfn-type="dfn">value object</dfn></dt><dd>
    A <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> is a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> that has an <code>@value</code>
    member.</dd>
  <dt><dfn id="dfn-vocabulary-mapping" data-dfn-type="dfn">vocabulary mapping</dfn></dt><dd>
    The vocabulary mapping is set in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> using the <code>@vocab</code> key whose
    value <em class="rfc2119" title="MUST">MUST</em> be an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> <code>null</code>.</dd></dl>
</div>

  <section id="algorithm-terms">
    <h4 id="x1-2-1-algorithm-terms"><span class="secno">1.2.1 </span>Algorithm Terms&nbsp;<span class="permalink"><a href="#algorithm-terms" aria-label="Permalink for 1.2.1 Algorithm Terms" title="Permalink for 1.2.1 Algorithm Terms"><span>§</span></a></span></h4>

    <p>The Following terms are used within specific algorithms.</p>

    <div data-oninclude="restrictReferences"><dl class="termlist" data-sort="" id="terms-0"><dt><dfn id="dfn-active-graph" data-dfn-type="dfn">active graph</dfn></dt><dd>
    The name of the currently active graph that the processor should use when
    processing.</dd>
  <dt></dt>
  <dt><dfn id="dfn-active-property" data-dfn-type="dfn">active property</dfn></dt><dd>
    The currently active <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a> or <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> that the processor
    should use when processing. The <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> is represented in
    the original lexical form, which is used for finding coercion mappings in
    the <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>.</dd>
  <dt></dt>
  <dt></dt>
  <dt></dt>
  <dt></dt>
  <dt><dfn id="dfn-json-ld-input" data-dfn-type="dfn">JSON-LD input</dfn></dt><dd>
    The JSON-LD data structure that is provided as input to the algorithm.</dd>
  <dt></dt>
  <dt></dt>
  <dt></dt>
  <dt></dt>
  <dt class="changed"></dt>
  <dt></dt>
  <dt><dfn data-lt="promises|promise" id="dfn-promises" data-dfn-type="dfn">promise</dfn></dt><dd>
    A <a class="externalDFN" href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise-objects">promise</a> is an object that represents the eventual result of a single asynchronous operation.
    Promises are defined in [<cite><a class="bibref" href="#bib-ECMASCRIPT-6.0">ECMASCRIPT-6.0</a></cite>].</dd>
  <dt></dt></dl>
</div>
  </section>

  </section>

  <section id="typographical-conventions">
    <h3 id="x1-3-typographical-conventions"><span class="secno">1.3 </span>Typographical conventions&nbsp;<span class="permalink"><a href="#typographical-conventions" aria-label="Permalink for 1.3 Typographical conventions" title="Permalink for 1.3 Typographical conventions"><span>§</span></a></span></h3>
    <div>      <p>The following typographic conventions are used in this specification:</p>

      <dl class="typography">
        <dt><code>markup</code></dt>
        <dd>Markup (elements, attributes, properties), machine processable values (string, characters, media types), property name, or a file name is in red-orange monospace font.</dd>
        <dt><var>variable</var></dt>
        <dd>A variable in pseudo-code or in an algorithm description is in italics.</dd>
        <dt><dfn data-dfn-type="dfn" id="dfn-definition">definition</dfn></dt>
        <dd>A definition of a term, to be used elsewhere in this or other specifications, is in bold and italics.</dd>
        <dt><a data-lt="definition" href="#dfn-definition" class="internalDFN" data-link-type="dfn">definition reference</a></dt>
        <dd>A reference to a definition <em>in this document</em> is underlined and is also an active link to the definition itself. </dd>
        <dt><a data-lt="definition" href="#dfn-definition" class="internalDFN" data-link-type="dfn"><code>markup definition reference</code></a></dt>
        <dd>A references to a definition <em>in this document</em>, when the reference itself is also a markup, is underlined, red-orange monospace font, and is also an active link to the definition itself.</dd>
        <dt><a class="externalDFN">external definition reference</a></dt>
        <dd>A reference to a definition <em>in another document</em> is underlined, in italics, and is also an active link to the definition itself.</dd>
        <dt><a class="externalDFN"><code> markup external definition reference</code></a></dt>
        <dd>A reference to a definition <em>in another document</em>, when the reference itself is also a markup, is underlined, in italics red-orange monospace font, and is also an active link to the definition itself.</dd>
        <dt><a href=".">hyperlink</a></dt>
        <dd>A hyperlink is underlined and in blue.</dd>
        <dt>[<a href=".">reference</a>]</dt>
        <dd>A document reference (normative or informative) is enclosed in square brackets and links to the references section.</dd>
        <dt class="changed">Changes from Recommendation</dt>
        <dd>Sections or phrases changed from the previous Recommendation are <span class="changed">highlighted</span>.</dd>
      </dl>

      <div class="note" id="issue-container-generatedID"><div role="heading" class="note-title marker" id="h-note" aria-level="4"><span>Note</span></div><p class="">Notes are in light green boxes with a green left border and with a "Note" header in green. Notes are normative or informative depending on the whether they are in a normative or informative section, respectively.</p></div>

      <div class="example"><div class="example-title marker"><span>Example 1</span></div><pre class="hljs javascript" aria-busy="false">Examples are <span class="hljs-keyword">in</span> light khaki boxes, <span class="hljs-keyword">with</span> khaki left border, and <span class="hljs-keyword">with</span> a
numbered <span class="hljs-string">"Example"</span> header <span class="hljs-keyword">in</span> khaki. Examples are always informative.
The content <span class="hljs-keyword">of</span> the example is <span class="hljs-keyword">in</span> monospace font and may be syntax colored.</pre></div>
</div>
  </section>

  <section id="example-conventions">
    <h3 id="x1-4-example-conventions"><span class="secno">1.4 </span>Example Conventions&nbsp;<span class="permalink"><a href="#example-conventions" aria-label="Permalink for 1.4 Example Conventions" title="Permalink for 1.4 Example Conventions"><span>§</span></a></span></h3>
    <p>Note that in the examples used in this document, output
      is of necessity shown in serialized form as JSON. While the algorithms
      describe operations on the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">JSON-LD internal representation</a>, when
      they as displayed as examples, the JSON serialization is used. In particular,
      the internal representation use of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are represented using
      <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a>.</p>

    <div class="example"><div class="example-title marker"><span>Example 2</span><span style="text-transform: none">: Sample JSON-LD document</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "knows": "http://xmlns.com/foaf/0.1/knows"
  },
  "@id": "http://me.markus-lanthaler.com/",
  "name": "Markus Lanthaler",
  "knows": [
    {
      "name": "Dave Longley"
    }
  ]
}</pre></div>
    <p>In the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>, the example above would be of a
      <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing <code>@context</code>, <code>@id</code>, <code>name</code>, and <code>knows</code> keys,
      with either <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>, <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>, or <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a> of
      dictionaries or strings values. In the JSON serialization, <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a> are used
      for dictionaries, while arrays and strings are serialized using a
      convention common to many programming languages.</p>
  </section>

</section> <!-- end of Introduction -->


<section class="informative" id="features">
  <!--OddPage--><h2 id="x2-features"><span class="secno">2. </span>Features&nbsp;<span class="permalink"><a href="#features" aria-label="Permalink for 2. Features" title="Permalink for 2. Features"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>

  <p>The JSON-LD 1.1 Syntax specification [<cite><a class="bibref" href="#bib-JSON-LD11CG">JSON-LD11CG</a></cite>] defines a syntax to
    express Linked Data in JSON. Because there is more than one way to
    express Linked Data using this syntax, it is often useful to be able to
    transform JSON-LD documents so that they may be more easily consumed by
    specific applications.</p>

  <p class="changed">To allow these algorithms to be adapted for syntaxes
    other than JSON, the algorithms operate on the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">JSON-LD internal representation</a>,
    which uses the generic
    concepts of <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>,
    <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>, <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a>, <a data-link-type="dfn" href="https://heycam.github.io/webidl/#idl-boolean">booleans</a>, and <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a> to describe
    the data represented by a JSON document. Algorithms act on this
    <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a> with API entry points responsible for
    transforming between the concrete and internal representations.</p>

  <p>JSON-LD uses <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">contexts</a> to allow Linked Data
    to be expressed in a way that is specifically tailored to a particular
    person or application. By providing a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>,
    JSON data can be expressed in a way that is a natural fit for a particular
    person or application whilst also indicating how the data should be
    understood at a global scale. In order for people or applications to
    share data that was created using a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> that is different
    from their own, a JSON-LD processor must be able to transform a document
    from one <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> to another. Instead of requiring JSON-LD
    processors to write specific code for every imaginable
    <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> switching scenario, it is much easier to specify a
    single algorithm that can remove any <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>. Similarly,
    another algorithm can be specified to subsequently apply any
    <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>. These two algorithms represent the most basic
    transformations of JSON-LD documents. They are referred to as
    <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expansion</a> and <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compaction</a>, respectively.</p>

  <p class="changed">JSON-LD 1.1 introduces new features that are
    compatible with <a href="https://www.w3.org/TR/json-ld/">JSON-LD 1.0</a> [<cite><a class="bibref" href="#bib-JSON-LD">JSON-LD</a></cite>],
    but if processed by a JSON-LD 1.0 processor may produce different results.
    In order to detect this JSON-LD 1.1 requires that the <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing
    mode</a> be explicitly set to <code>json-ld-1.1</code>, either through the
    <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a> API option, or using the
    <code>@version</code> member within a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>.</p>

  <p>There are four major types of transformation that are discussed in this
    document: expansion, compaction, flattening, and RDF serialization/deserialization.</p>

  <section class="informative" id="expansion">
    <h3 id="x2-1-expansion"><span class="secno">2.1 </span>Expansion&nbsp;<span class="permalink"><a href="#expansion" aria-label="Permalink for 2.1 Expansion" title="Permalink for 2.1 Expansion"><span>§</span></a></span></h3><p><em>This section is non-normative.</em></p>

    <p>The algorithm that removes <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> is
      called <dfn data-lt="expanded|expanding|expansion" data-dfn-type="dfn" id="dfn-expanded">expansion</dfn>. Before performing any other
      transformations on a JSON-LD document, it is easiest to
      remove any <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> from it and to make data structures
      more regular.</p>

    <p>To get an idea of how context and data structuring affects the same data,
      here is an example of JSON-LD that uses only <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a>
      and is fairly compact:</p>

    <div class="example"><div class="example-title marker"><span>Example 3</span><span style="text-transform: none">: JSON-LD documenet using only terms</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "homepage": {
      "@id": "http://xmlns.com/foaf/0.1/homepage",
      "@type": "@id"
    }
  },
  "@id": "http://me.markus-lanthaler.com/",
  "name": "Markus Lanthaler",
  "homepage": "http://www.markus-lanthaler.com/"
}</pre></div>

    <script type="application/ld+json" data-api="expand">
      [
        {
          "@id": "http://me.markus-lanthaler.com/",
          "http://xmlns.com/foaf/0.1/homepage": [
            {
              "@id": "http://www.markus-lanthaler.com/"
            }
          ],
          "http://xmlns.com/foaf/0.1/name": [
            {
              "@value": "Markus Lanthaler"
            }
          ]
        }
      ]
    </script>

    <p>The next input example uses one <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> to express a property
    and an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> to encapsulate another, but
    leaves the rest of the information untouched.</p>

    <div class="example"><div class="example-title marker"><span>Example 4</span><span style="text-transform: none">: Sample JSON-LD document using an IRI instead of a term to express a property</span></div><pre class="nohighlight">{
  "@context": {
    <span class="hl-bold">"website": "http://xmlns.com/foaf/0.1/homepage"</span>
  },
  "@id": "http://me.markus-lanthaler.com/",
  "<span class="hl-bold">http://xmlns.com/foaf/0.1/name</span>": "Markus Lanthaler",
  <span class="hl-bold">"website"</span>: <span class="hl-bold">{ "@id":</span> "http://www.markus-lanthaler.com/" <span class="hl-bold">}</span>
}</pre></div>

    <p>Note that both inputs are valid JSON-LD and both represent the same
      information. The difference is in their <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> information
      and in the data structures used. A JSON-LD processor can remove
      <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> and ensure that the data is more regular by employing
      <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expansion</a>.</p>

    <p><a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">Expansion</a> has two important goals: removing any contextual
      information from the document, and ensuring all values are represented
      in a regular form. These goals are accomplished by expanding all properties
      to <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute IRIs</a> and by expressing all
      values in <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a> in
      <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a>. <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">Expanded form</a> is the most verbose
      and regular way of expressing of values in JSON-LD; all contextual
      information from the document is instead stored locally with each value.
      Running the <a href="#expansion-algorithm">Expansion algorithm</a>
      (<a data-link-for="JsonLdProcessor" href="#dom-jsonldprocessor-expand" class="internalDFN" data-link-type="dfn"><code>expand</code></a>)
      operation) against the above examples results in the following output:</p>

    <div class="example"><div class="example-title marker"><span>Example 5</span><span style="text-transform: none">: Expanded JSON-LD document using an IRI</span></div><pre class="nohighlight">[
  {
    "@id": "http://me.markus-lanthaler.com/",
    "http://xmlns.com/foaf/0.1/name": [
      { "@value": "Markus Lanthaler" }
    ],
    "http://xmlns.com/foaf/0.1/homepage": [
      { "@id": "http://www.markus-lanthaler.com/" }
    ]
  }
]</pre></div>

    <p class="changed">The example above is the JSON-LD serialization of the output of the
      <a href="#expansion-algorithm">expansion algorithm</a>,
      where the algorithm's use of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are replaced with <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a>.</p>

    <p>Note that in the output above all <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> definitions have
      been removed, all <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> and
      <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a> have been expanded to absolute
      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a>, and all
      <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a> are expressed in
      <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a> in <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a>. While the
      output is more verbose and difficult for a human to read, it establishes a
      baseline that makes JSON-LD processing easier because of its very regular
      structure.</p>
  </section> <!-- end of Expansion -->

  <section class="informative" id="compaction">
    <h3 id="x2-2-compaction"><span class="secno">2.2 </span>Compaction&nbsp;<span class="permalink"><a href="#compaction" aria-label="Permalink for 2.2 Compaction" title="Permalink for 2.2 Compaction"><span>§</span></a></span></h3><p><em>This section is non-normative.</em></p>

    <p>While <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expansion</a> removes <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> from a given
      input, <dfn data-lt="compact|compacting|compacted|compacts|compaction" data-dfn-type="dfn" id="dfn-compact">compaction</dfn>'s primary function is to
      perform the opposite operation: to express a given input according to
      a particular <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>. <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">Compaction</a> applies a
      <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> that specifically tailors the way information is
      expressed for a particular person or application. This simplifies applications
      that consume JSON or JSON-LD by expressing the data in application-specific
      terms, and it makes the data easier to read by humans.</p>

    <p><a href="#dfn-compact" class="internalDFN" data-link-type="dfn">Compaction</a> uses a developer-supplied <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> to
      shorten <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> to <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> or
      <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a> and
      <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a> expressed in
      <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a> to simple values such as <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>
      or <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a>.</p>

    <p>For example, assume the following expanded JSON-LD input document:</p>

    <div class="example"><div class="example-title marker"><span>Example 6</span><span style="text-transform: none">: Expanded sample document</span></div><pre class="nohighlight">[
  {
    "@id": "http://me.markus-lanthaler.com/",
    "http://xmlns.com/foaf/0.1/name": [
      { "@value": "Markus Lanthaler" }
    ],
    "http://xmlns.com/foaf/0.1/homepage": [
      { "@id": "http://www.markus-lanthaler.com/" }
    ]
  }
]</pre></div>

    <p>Additionally, assume the following developer-supplied JSON-LD
      <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>:</p>

    <div class="example"><div class="example-title marker"><span>Example 7</span><span style="text-transform: none">: JSON-LD context</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "homepage": {
      "@id": "http://xmlns.com/foaf/0.1/homepage",
      "@type": "@id"
    }
  }
}</pre></div>

    <p>Running the <a href="#compaction-algorithm">Compaction Algorithm</a>
      (<a data-link-for="JsonLdProcessor" href="#dom-jsonldprocessor-compact" class="internalDFN" data-link-type="dfn"><code>compact</code></a>)
      operation) given the context supplied above against the JSON-LD input
      document provided above would result in the following output:</p>

    <div class="example"><div class="example-title marker"><span>Example 8</span><span style="text-transform: none">: Compacted sample document</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "homepage": {
      "@id": "http://xmlns.com/foaf/0.1/homepage",
      "@type": "@id"
    }
  },
  "@id": "http://me.markus-lanthaler.com/",
  "name": "Markus Lanthaler",
  "homepage": "http://www.markus-lanthaler.com/"
}</pre></div>

    <p class="changed">The example above is the JSON-LD serialization of the output of the
      <a href="#compaction-algorithm">compaction algorithm</a>,
      where the algorithm's use of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are replaced with <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a>.</p>

    <p>Note that all <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> have been compacted to
      <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> as specified in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>,
      which has been injected into the output. While compacted output is
      useful to humans, it is also used to generate structures that are easy to
      program against. Compaction enables developers to map any expanded document
      into an application-specific compacted document. While the context provided
      above mapped <code>http://xmlns.com/foaf/0.1/name</code> to <code>name</code>, it
      could also have been mapped to any other term provided by the developer.</p>
  </section> <!-- end of Compaction -->

  <section class="informative" id="flattening">
    <h3 id="x2-3-flattening"><span class="secno">2.3 </span>Flattening&nbsp;<span class="permalink"><a href="#flattening" aria-label="Permalink for 2.3 Flattening" title="Permalink for 2.3 Flattening"><span>§</span></a></span></h3><p><em>This section is non-normative.</em></p>

    <p>While expansion ensures that a document is in a uniform structure,
      <dfn data-lt="flattened|flattening" data-dfn-type="dfn" id="dfn-flattened">flattening</dfn> goes a step further to ensure that the shape of the data
      is deterministic. In expanded documents, the properties of a single
      <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> may be spread across a number of different
      <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>. By flattening a
      document, all properties of a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> are collected in a single
      <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> and all <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank nodes</a>
      are labeled with a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>. This may drastically
      simplify the code required to process JSON-LD data in certain applications.</p>

    <p>For example, assume the following JSON-LD input document:</p>

    <div class="example"><div class="example-title marker"><span>Example 9</span><span style="text-transform: none">: JSON-LD document in compact form</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "knows": "http://xmlns.com/foaf/0.1/knows"
  },
  "@id": "http://me.markus-lanthaler.com/",
  "name": "Markus Lanthaler",
  "knows": [
    {
      "name": "Dave Longley"
    }
  ]
}</pre></div>

    <p>Running the <a href="#flattening-algorithm">Flattening Algorithm</a>
      (<a data-link-for="JsonLdProcessor" href="#dom-jsonldprocessor-flatten" class="internalDFN" data-link-type="dfn"><code>flatten</code></a>)
      operation) with a context set to <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a> to prevent compaction
      returns the following document:</p>

    <div class="example"><div class="example-title marker"><span>Example 10</span><span style="text-transform: none">: Flattened sample document in expanded form</span></div><pre class="nohighlight">[
  {
    "@id": "_:t0",
    "http://xmlns.com/foaf/0.1/name": [
      { "@value": "Dave Longley" }
    ]
  },
  {
    "@id": "http://me.markus-lanthaler.com/",
    "http://xmlns.com/foaf/0.1/name": [
      { "@value": "Markus Lanthaler" }
    ],
    "http://xmlns.com/foaf/0.1/knows": [
      { "@id": "_:t0" }
    ]
  }
]</pre></div>

    <p class="changed">The example above is the JSON-LD serialization of the output of the
      <a href="#flattening-algorithm">flattening algorithm</a>,
      where the algorithm's use of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are replaced with <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a>.</p>

    <p>Note how in the output above all properties of a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> are collected in a
      single <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> and how the <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a> representing
      "Dave Longley" has been assigned the <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>
      <code>_:t0</code>.</p>

    <p>To make it easier for humans to read or for certain applications to
      process it, a flattened document can be compacted by passing a context. Using
      the same context as the input document, the flattened and compacted document
      looks as follows:</p>

    <div class="example"><div class="example-title marker"><span>Example 11</span><span style="text-transform: none">: Flattened and compacted sample document</span></div><pre class="nohighlight">{
  "@context": {
    "name": "http://xmlns.com/foaf/0.1/name",
    "knows": "http://xmlns.com/foaf/0.1/knows"
  },
  "@graph": [
    {
      "@id": "_:t0",
      "name": "Dave Longley"
    }, {
      "@id": "http://me.markus-lanthaler.com/",
      "name": "Markus Lanthaler",
      "knows": { "@id": "_:t0" }
    }
  ]
}</pre></div>

    <p>Please note that the result of flattening and <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> a document
      is always a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>,
      <span class="changed">(represented as a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON object</a> when serialized)</span>,
      which contains an <code>@graph</code>
      member that represents the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a>.</p>
  </section> <!-- end of Flattening -->

  <section class="informative" id="rdf-serialization-deserialization">
    <h3 id="x2-4-rdf-serialization-deserialization"><span class="secno">2.4 </span>RDF Serialization/Deserialization&nbsp;<span class="permalink"><a href="#rdf-serialization-deserialization" aria-label="Permalink for 2.4 RDF Serialization/Deserialization" title="Permalink for 2.4 RDF Serialization/Deserialization"><span>§</span></a></span></h3><p><em>This section is non-normative.</em></p>

    <p>JSON-LD can be used to serialize RDF data as described in
      [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>]. This ensures that data can be round-tripped to and from
      any RDF syntax without any loss in fidelity.</p>

    <p>For example, assume the following RDF input serialized in Turtle [<cite><a class="bibref" href="#bib-TURTLE">TURTLE</a></cite>]:</p>

    <div class="example"><div class="example-title marker"><span>Example 12</span><span style="text-transform: none">: Sample Turtle document</span></div><pre class="nohighlight" data-content-type="text/turtle">&lt;http://me.markus-lanthaler.com/&gt; &lt;http://xmlns.com/foaf/0.1/name&gt; "Markus Lanthaler" .
&lt;http://me.markus-lanthaler.com/&gt; &lt;http://xmlns.com/foaf/0.1/homepage&gt; &lt;http://www.markus-lanthaler.com/&gt; .</pre></div>

    <p>Using the <a href="#serialize-rdf-as-json-ld-algorithm">Serialize RDF as JSON-LD algorithm</a>
      a developer could transform this document into expanded JSON-LD:</p>

    <div class="example"><div class="example-title marker"><span>Example 13</span><span style="text-transform: none">: Sample Turtle document converted to JSON-LD</span></div><pre class="nohighlight">[
  {
    "@id": "http://me.markus-lanthaler.com/",
    "http://xmlns.com/foaf/0.1/name": [
      { "@value": "Markus Lanthaler" }
    ],
    "http://xmlns.com/foaf/0.1/homepage": [
      { "@id": "http://www.markus-lanthaler.com/" }
    ]
  }
]</pre></div>

    <p class="changed">The example above is the JSON-LD serialization of the output of the
      <a href="#serialize-rdf-as-json-ld-algorithm">Serialize RDF as JSON-LD algorithm</a>,
      where the algorithm's use of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are replaced with <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON objects</a>.</p>

    <p>Note that the output above could easily be compacted using the technique outlined
      in the previous section. It is also possible to deserialize the JSON-LD document back
      to RDF using the <a href="#deserialize-json-ld-to-rdf-algorithm">Deserialize JSON-LD to RDF algorithm</a>.</p>
  </section> <!-- end of RDF Serialization/Deserialization -->
</section> <!-- end of Features section -->


<section id="conformance"><!--OddPage--><h2 id="x3-conformance"><span class="secno">3. </span>Conformance&nbsp;<span class="permalink"><a href="#conformance" aria-label="Permalink for 3. Conformance" title="Permalink for 3. Conformance"><span>§</span></a></span></h2><p>
  As well as sections marked as non-normative, all authoring guidelines, diagrams, examples,
  and notes in this specification are non-normative. Everything else in this specification is
  normative.
</p><p id="respecRFC2119">The key words  <em class="rfc2119">MAY</em>, <em class="rfc2119">MUST</em>, and <em class="rfc2119">MUST NOT</em> are
  to be interpreted as described in [<cite><a class="bibref" href="#bib-RFC2119">RFC2119</a></cite>].
</p>
  <p>There are two classes of products that can claim conformance to this
    specification: <a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processors</a>,
    and <a href="#dfn-rdf-serializers-deserializers" class="internalDFN" data-link-type="dfn">RDF Serializers/Deserializers</a>.</p>

  <p>A conforming <a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processor</a> is a system which can perform the
    <a href="#expansion-algorithm">Expansion</a>, <a href="#compaction-algorithm">Compaction</a>,
    and <a href="#flattening-algorithm">Flattening</a> operations
    <span class="changed">in a manner consistent with
      the algorithms defined in this specification</span>.</p>

  <p><a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processors</a> <em class="rfc2119" title="MUST NOT">MUST NOT</em>
    attempt to correct malformed <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> or language tags;
    however, they <em class="rfc2119" title="MAY">MAY</em> issue validation warnings. IRIs are not modified other
    than conversion between <a data-lt="relative IRI" href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative</a> and
    <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute IRIs</a>.</p>

  <p>A conforming <dfn data-lt="rdf serializers/deserializers|rdf serializer/deserializer" data-dfn-type="dfn" id="dfn-rdf-serializers-deserializers">RDF Serializer/Deserializer</dfn> is a system that can
    <a href="#deserialize-json-ld-to-rdf-algorithm">deserialize JSON-LD to RDF</a> and
    <a href="#serialize-rdf-as-json-ld-algorithm">serialize RDF as JSON-LD</a> as
    defined in this specification.</p>

  <p>The algorithms in this specification are generally written with more concern for clarity
    than efficiency. Thus, <a href="#dfn-json-ld-processors" class="internalDFN" data-link-type="dfn">JSON-LD Processors</a> may
    implement the algorithms given in this specification in any way desired,
    so long as the end result is indistinguishable from the result that would
    be obtained by the specification's algorithms.</p>

  <p>In algorithm steps that describe operations on <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a>, those steps
    also apply to <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword aliases</a>.</p>

  <div class="note" id="issue-container-generatedID-0"><div role="heading" class="note-title marker" id="h-note-0" aria-level="3"><span>Note</span></div><p class="">Implementers can partially check their level of conformance to
    this specification by successfully passing the test cases of the JSON-LD test
    suite [<cite><a class="bibref" href="#bib-JSON-LD-TESTS">JSON-LD-TESTS</a></cite>]. Note, however, that passing all the tests in the test
    suite does not imply complete conformance to this specification. It only implies
    that the implementation conforms to aspects tested by the test suite.</p></div>
</section> <!-- end of Conformance section -->

<section id="context-processing-algorithms">
  <!--OddPage--><h2 id="x4-context-processing-algorithms"><span class="secno">4. </span>Context Processing Algorithms&nbsp;<span class="permalink"><a href="#context-processing-algorithms" aria-label="Permalink for 4. Context Processing Algorithms" title="Permalink for 4. Context Processing Algorithms"><span>§</span></a></span></h2>

  <section id="context-processing-algorithm">
    <h3 id="x4-1-context-processing-algorithm"><span class="secno">4.1 </span>Context Processing Algorithm&nbsp;<span class="permalink"><a href="#context-processing-algorithm" aria-label="Permalink for 4.1 Context Processing Algorithm" title="Permalink for 4.1 Context Processing Algorithm"><span>§</span></a></span></h3>

    <p>When processing a JSON-LD data structure, each processing rule is applied
      using information provided by the <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>. This
      section describes how to produce an <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>.</p>

    <p>The <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> contains the active
      <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definitions</a> which specify how
      properties and values have to be interpreted as well as the current <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
      the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a> and the <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>. Each
      <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> consists of an <dfn data-lt="iri mappings|iri mapping" data-dfn-type="dfn" id="dfn-iri-mappings"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</dfn>, a boolean
      flag <dfn data-lt="reverse properties|reverse property" data-dfn-type="dfn" id="dfn-reverse-properties">reverse property</dfn>, an optional <dfn data-lt="type mappings|type mapping" data-dfn-type="dfn" id="dfn-type-mappings">type mapping</dfn>
      or <dfn data-lt="language mappings|language mapping" data-dfn-type="dfn" id="dfn-language-mappings">language mapping</dfn>,
      <span class="changed">an optional <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a></span>,
      <span class="changed">an optional <dfn data-dfn-type="dfn" id="dfn-nest-value">nest value</dfn>,</span>
      <span class="changed">an optional <dfn data-dfn-type="dfn" id="dfn-prefix-flag">prefix flag</dfn>,</span>
      and an optional <dfn data-lt="container mappings|container mapping" data-dfn-type="dfn" id="dfn-container-mappings">container mapping</dfn>.
      A <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> can not only be used to map a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
      to an <abbr title="Internationalized Resource Identifier">IRI</abbr>, but also to map a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> to a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>,
      in which case it is referred to as a <dfn data-lt="keyword aliases|keyword alias" data-dfn-type="dfn" id="dfn-keyword-aliases">keyword alias</dfn>.</p>

    <p>When processing, <var>active context</var> is initialized
      without any <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definitions</a>,
      <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, or <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>.
      If a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> is encountered during processing, a new
      <var>active context</var> is created by cloning the existing
      <var>active context</var>. Then the information from the
      <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> is merged into the new <var>active context</var>.
      Given that <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local contexts</a> may contain
      references to remote contexts, this includes their retrieval.</p>

    <section class="informative" id="overview">
      <h4 id="x4-1-1-overview"><span class="secno">4.1.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview" aria-label="Permalink for 4.1.1 Overview" title="Permalink for 4.1.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>First we prepare a new <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> <var>result</var> by cloning
        the current <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>. Then we normalize the form of the <span class="changed">original</span>
        <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.
        <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">Local contexts</a> may be in the form of a
        <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, or an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing
        a combination of the two. Finally we process each <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> contained
        in the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> as follows.</p>

      <p class="changed">Unless specified using
        <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a> API option,
        the <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a> is set using the <code>@version</code> member
        in a local <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> and
        affects the behavior of algorithms including <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expansion</a> and <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compaction</a>.</p>

      <p>If <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, it represents a reference to
        a remote context. We dereference the remote context and replace <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>
        with the value of the <code>@context</code> key of the top-level object in the
        retrieved JSON-LD document. If there's no such key, an
        <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-remote-context" class="internalDFN" data-link-type="dfn"><code>invalid remote context</code></a>
        has been detected. Otherwise, we process <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> by recursively using
        this algorithm ensuring that there is no cyclical reference.</p>

      <p>If <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, we first update the
        <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>, and the
        <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a> by processing three specific keywords:
        <code>@base</code>, <code>@vocab</code>, <code>@version</code>, and <code>@language</code>.
        These are handled before any other keys in the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> because
        they affect how the other keys are processed. Please note that <code>@base</code> is
        ignored when processing remote contexts.</p>

      <p>Then, for every other key in <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, we update
        the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>result</var>. Since
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definitions</a> in a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>
        may themselves contain <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> or
        <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a>, we may need to recurse.
        When doing so, we must ensure that there is no cyclical dependency,
        which is an error. After we have processed any
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> dependencies,
        we update the current <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>,
        which may be a <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword alias</a>.</p>

      <p>Finally, we return <var>result</var> as the new <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>.</p>
    </section>

    <section class="algorithm" id="algorithm">
      <h4 id="x4-1-2-algorithm"><span class="secno">4.1.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm" aria-label="Permalink for 4.1.2 Algorithm" title="Permalink for 4.1.2 Algorithm"><span>§</span></a></span></h4>

      <p>This algorithm specifies how a new <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> is updated
        with a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>. The algorithm takes three input variables:
        an <var>active context</var>, a <var>local context</var>, and an  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
        <var>remote contexts</var> which is used to detect cyclical context inclusions.
        If <var>remote contexts</var> is not passed, it is initialized to an empty
        <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</p>

      <ol>
        <li>Initialize <var>result</var> to the result of cloning
          <var>active context</var>.</li>
        <li>If <var>local context</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
          set it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only
          <var>local context</var>.</li>
        <li>
          For each item <var>context</var> in <var>local context</var>:
          <ol>
            <li>If <var>context</var> is <code>null</code>, set <var>result</var> to a
              newly-initialized <var>active context</var> and continue with the
              next <var>context</var>.
              <span class="note">In JSON-LD 1.0, the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> was given
                a default value here; this is now described conditionally
                in <a href="#the-application-programming-interface" class="sectionRef sec-ref">section <span class="secno">9.</span> <span class="sec-title">The Application Programming Interface</span></a>.</span></li>
            <li>If <var>context</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,
              <ol>
                <li>Set <var>context</var> to the result of resolving <var>value</var> against
                  the base <abbr title="Internationalized Resource Identifier">IRI</abbr> which is established as specified in
                  <a href="https://tools.ietf.org/html/rfc3986#section-5.1">section 5.1 Establishing a Base URI</a>
                  of [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>]. Only the basic algorithm in
                  <a href="https://tools.ietf.org/html/rfc3986#section-5.2">section 5.2</a>
                  of [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>] is used; neither
                  <a href="https://tools.ietf.org/html/rfc3986#section-6.2.2">Syntax-Based Normalization</a> nor
                  <a href="https://tools.ietf.org/html/rfc3986#section-6.2.3">Scheme-Based Normalization</a>
                  are performed. Characters additionally allowed in <abbr title="Internationalized Resource Identifier">IRI</abbr>
                  references are treated in the same way that unreserved
                  characters are treated in URI references, per
                  <a href="https://tools.ietf.org/html/rfc3987#section-6.5">section 6.5</a>
                  of [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>].</li>
                <li>If <var>context</var> is in the <var>remote contexts</var> array, a
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-recursive-context-inclusion" class="internalDFN" data-link-type="dfn"><code>recursive context inclusion</code></a>
                  error has been detected and processing is aborted;
                  otherwise, add <var>context</var> to <var>remote contexts</var>.</li>
                <li class="changed">If <var>context</var> was previously dereferenced,
                  then the processor <em class="rfc2119" title="MUST NOT">MUST NOT</em> do a further dereference, and
                  <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> is set to the
                  previously established <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>.</li>
                <li>Otherwise, dereference <var>context</var>, <span class="changed">transforming into the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a></span>.
                  If <var>context</var> cannot be dereferenced,
                  <span class="changed">or cannot be transformed into the <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a></span>,
                  a <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-loading-remote-context-failed" class="internalDFN" data-link-type="dfn"><code>loading remote context failed</code></a>
                  error has been detected and processing is aborted. If the dereferenced document has no
                  top-level <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with an <code>@context</code> member, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-remote-context" class="internalDFN" data-link-type="dfn"><code>invalid remote context</code></a>
                  has been detected and processing is aborted; otherwise,
                  set <var>context</var> to the value of that member.</li>
                <li>Set <var>result</var> to the result of recursively calling this algorithm,
                  passing <var>result</var> for <var>active context</var>,
                  <var>context</var> for <var>local context</var>, and <span class="changed">a copy of</span> <var>remote contexts</var>.</li>
                <li>Continue with the next <var>context</var>.</li>
              </ol>
            </li>
            <li>If <var>context</var> is not a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-local-context" class="internalDFN" data-link-type="dfn"><code>invalid local context</code></a>
              error has been detected and processing is aborted.</li>
            <li>If <var>context</var> has an <code>@base</code> key and <var>remote contexts</var> is empty, i.e., the currently
              being processed context is not a remote context:
              <ol>
                <li>Initialize <var>value</var> to the value associated with the
                  <code>@base</code> key.</li>
                <li>If <var>value</var> is <code>null</code>, remove the
                  <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> of <var>result</var>.</li>
                <li>Otherwise, if <var>value</var> is an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
                  the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> of <var>result</var> is set to <var>value</var>.</li>
                <li>Otherwise, if <var>value</var> is a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> and
                  the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> of <var>result</var> is not <code>null</code>,
                  set the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> of <var>result</var> to the result of
                  resolving <var>value</var> against the current <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
                  of <var>result</var>.</li>
                <li>Otherwise, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-base-iri" class="internalDFN" data-link-type="dfn"><code>invalid base <abbr title="Internationalized Resource Identifier">IRI</abbr></code></a>
                  error has been detected and processing is aborted.</li>
              </ol>
            </li>
            <li class="changed">If <var>context</var> has an <code>@version</code> key:
              <ol>
                <li>If the associated value is not <code>1.1</code>,
                  an <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--version-value" class="internalDFN" data-link-type="dfn"><code>invalid @version value</code></a>
                  has been detected, and processing is aborted.</li>
                <li>If <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>
                  is set to <code>json-ld-1.0</code>,
                  a <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-processing-mode-conflict" class="internalDFN" data-link-type="dfn"><code>processing mode conflict</code></a>
                  error has been detected and processing is aborted.</li>
                <li>Set <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>,
                  to <code>json-ld-1.1</code>, if not already set.</li>
              </ol>
            </li>
            <li>If <var>context</var> has an <code>@vocab</code> key:
              <ol>
                <li>Initialize <var>value</var> to the value associated with the
                  <code>@vocab</code> key.</li>
                <li>If <var>value</var> is <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a>, remove
                  any <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a> from <var>result</var>.</li>
                <li class="changed">Otherewise, if <var>value</var>
                  the empty string (<code>""</code>),
                  the effective value is the current <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</li>
                <li>Otherwise, if <var>value</var> is
                  an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
                  or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>
                  of <var>result</var> is set to <var>value</var>. If it is not
                  an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-vocab-mapping" class="internalDFN" data-link-type="dfn"><code>invalid vocab mapping</code></a>
                  error has been detected and processing is aborted.</li>
              </ol>
            </li>
            <li>If <var>context</var> has an <code>@language</code> key:
              <ol>
                <li>Initialize <var>value</var> to the value associated with the
                  <code>@language</code> key.</li>
                <li>If <var>value</var> is <code>null</code>, remove
                  any <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a> from <var>result</var>.</li>
                <li>Otherwise, if <var>value</var> is <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, the
                  <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a> of <var>result</var> is set to
                  lowercased <var>value</var>. If it is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-default-language" class="internalDFN" data-link-type="dfn"><code>invalid default language</code></a>
                  error has been detected and processing is aborted.</li>
              </ol>
            </li>
            <li>Create a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>defined</var> to use to keep
              track of whether or not a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> has already been defined
              or currently being defined during recursion.</li>
            <li>For each <var>key</var>-<var>value</var> pair in <var>context</var> where
              <var>key</var> is not <code>@base</code>, <code>@vocab</code>, or
              <code>@language</code>, invoke the
              <a href="#create-term-definition">Create Term Definition algorithm</a>,
              passing <var>result</var> for <var>active context</var>,
              <var>context</var> for <var>local context</var>, <var>key</var>,
              and <var>defined</var>.</li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Context Processing -->

  <section id="create-term-definition">
    <h3 id="x4-2-create-term-definition"><span class="secno">4.2 </span>Create Term Definition&nbsp;<span class="permalink"><a href="#create-term-definition" aria-label="Permalink for 4.2 Create Term Definition" title="Permalink for 4.2 Create Term Definition"><span>§</span></a></span></h3>

    <p>This algorithm is called from the
      <a href="#context-processing-algorithm">Context Processing algorithm</a>
      to create a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in the <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>
      for a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> being processed in a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>.</p>

    <section class="informative" id="overview-0">
      <h4 id="x4-2-1-overview"><span class="secno">4.2.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-0" aria-label="Permalink for 4.2.1 Overview" title="Permalink for 4.2.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p><a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definitions</a> are created by
        parsing the information in the given <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> for the
        given <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>. If the given <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> is a
        <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, it may omit an <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> by
        depending on its <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> having its own
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>. If the <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> is
        a key in the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, then its <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
        must first be created, through recursion, before continuing. Because a
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> can depend on other
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definitions</a>, a mechanism must
        be used to detect cyclical dependencies. The solution employed here
        uses a map, <var>defined</var>, that keeps track of whether or not a
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> has been defined or is currently in the process of
        being defined. This map is checked before any recursion is attempted.</p>

      <p>After all dependencies for a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> have been defined, the rest of
        the information in the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> for the given
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> is taken into account, creating the appropriate
        <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>, <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>, and
        <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> for the
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-0">
      <h4 id="x4-2-2-algorithm"><span class="secno">4.2.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-0" aria-label="Permalink for 4.2.2 Algorithm" title="Permalink for 4.2.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm has four required inputs which are:
        an <var>active context</var>, a <var>local context</var>,
        a <var>term</var>, and a map <var>defined</var>.</p>

      <ol>
        <li>If <var>defined</var> contains the key <var>term</var> and the associated
          value is <code>true</code> (indicating that the
          <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> has already been created), return. Otherwise,
          if the value is <code>false</code>, a
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-cyclic-iri-mapping" class="internalDFN" data-link-type="dfn"><code>cyclic <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
          error has been detected and processing is aborted.</li>
        <li>Set the value associated with <var>defined</var>'s <var>term</var> key to
          <code>false</code>. This indicates that the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
          is now being created but is not yet complete.</li>
        <li>Since <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> cannot be overridden,
          <var>term</var> must not be a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>. Otherwise, a
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-keyword-redefinition" class="internalDFN" data-link-type="dfn"><code>keyword redefinition</code></a>
          error has been detected and processing is aborted.</li>
        <li>Remove any existing <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>term</var> in
          <var>active context</var>.</li>
        <li>Initialize <var>value</var> to a copy of the value associated with the key
          <var>term</var> in <var>local context</var>.</li>
        <li>If <var>value</var> is <code>null</code> or <var>value</var>
          is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing the key-value pair
          <code>@id</code>-<code>null</code>, set the
          <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var> to
          <code>null</code>, set the value associated with <var>defined</var>'s
          key <var>term</var> to <code>true</code>, and return.</li>
        <li>Otherwise, if <var>value</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, convert it
          to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of a single member whose
          key is <code>@id</code> and whose value is <var>value</var>.
          <span class="changed">Set <var>simple term</var> to <code>true</code></span>.</li>
        <li>Otherwise, <var>value</var> must be a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, if not, an
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-term-definition" class="internalDFN" data-link-type="dfn"><code>invalid term definition</code></a>
          error has been detected and processing is aborted.
          <span class="changed">Set <var>simple term</var> to <code>false</code></span>.</li>
        <li>Create a new <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>, <var>definition</var>.</li>
        <li>If <var>value</var> contains the key <code>@type</code>:
          <ol>
            <li>Initialize <var>type</var> to the value associated with the
              <code>@type</code> key, which must be a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>. Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-type-mapping" class="internalDFN" data-link-type="dfn"><code>invalid type mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>Set <var>type</var> to the result of using the
              <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, passing
              <var>active context</var>, <var>type</var> for <var>value</var>,
              <code>true</code> for <var>vocab</var>,
              <var>local context</var>, and <var>defined</var>. If the expanded <var>type</var> is
              neither <code>@id</code>, nor <code>@vocab</code>, nor an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-type-mapping" class="internalDFN" data-link-type="dfn"><code>invalid type mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>Set the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> for <var>definition</var> to <var>type</var>.</li>
          </ol>
        </li>
        <li>If <var>value</var> contains the key <code>@reverse</code>:
          <ol>
            <li>If <var>value</var> contains <code>@id</code> or <code>@nest</code>, members, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-reverse-property" class="internalDFN" data-link-type="dfn"><code>invalid reverse property</code></a>
              error has been detected and processing is aborted.</li>
            <li>If the value associated with the <code>@reverse</code> key
              is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-iri-mapping" class="internalDFN" data-link-type="dfn"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>Otherwise, set the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <var>definition</var> to the
              result of using the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
              passing <var>active context</var>, the value associated with
              the <code>@reverse</code> key for <var>value</var>, <code>true</code>
              for <var>vocab</var>,
              <var>local context</var>, and <var>defined</var>. If the result
              is neither an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> nor a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,
              i.e., it contains no colon (<code>:</code>), an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-iri-mapping" class="internalDFN" data-link-type="dfn"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>If <var>value</var> contains an <code>@container</code> member,
              set the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> of <var>definition</var>
              to its value; if its value is neither <code>@set</code>, nor
              <code>@index</code>, nor <code>null</code>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-reverse-property" class="internalDFN" data-link-type="dfn"><code>invalid reverse property</code></a>
              error has been detected (reverse properties only support set- and
              index-containers) and processing is aborted.</li>
            <li>Set the <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a> flag of <var>definition</var>
              to <code>true</code>.</li>
            <li>Set the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> of <var>term</var> in
              <var>active context</var> to <var>definition</var> and the
              value associated with <var>defined</var>'s key <var>term</var> to
              <code>true</code> and return.</li>
          </ol>
        </li>
        <li>Set the <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a> flag of <var>definition</var>
          to <code>false</code>.</li>
        <li>If <var>value</var> contains the key <code>@id</code> and its value
          does not equal <var>term</var>:
          <ol>
            <li>If the value associated with the <code>@id</code> key is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-iri-mapping" class="internalDFN" data-link-type="dfn"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>Otherwise, set the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <var>definition</var> to the
              result of using the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, passing
              <var>active context</var>, the value associated with the <code>@id</code> key for
              <var>value</var>, <code>true</code> for <var>vocab</var>,
              <var>local context</var>, and <var>defined</var>. If the resulting
              <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> is neither a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>, nor an
              <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, nor a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-iri-mapping" class="internalDFN" data-link-type="dfn"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
              error has been detected and processing is aborted; if it equals <code>@context</code>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-keyword-alias" class="internalDFN" data-link-type="dfn"><code>invalid keyword alias</code></a>
              error has been detected and processing is aborted.</li>
            <li class="changed">If <var>term</var> does not contain a colon (<code>:</code>),
              <span class="changed"><var>simple term</var> is <code>true</code></span>, and the,
              <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <var>definition</var> ends with a URI
              <a href="https://tools.ietf.org/html/rfc3986#section-2.2">gen-delim</a> character,
              set the <a href="#dfn-prefix-flag" class="internalDFN" data-link-type="dfn">prefix flag</a> in <var>definition</var> to <code>true</code>.</li>
          </ol>
        </li>
        <li>
          Otherwise if the <var>term</var> contains a colon (<code>:</code>):
          <ol>
            <li>If <var>term</var> is a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> with a
              <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> that is a key in <var>local context</var>
              a dependency has been found. Use this algorithm recursively passing
              <var>active context</var>, <var>local context</var>, the
              <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> as <var>term</var>, and <var>defined</var>.</li>
            <li>If <var>term</var>'s <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> has a
              <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var>, set
              the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> of <var>definition</var> to the result of
              concatenating the value associated with the <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a>'s
              <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> and the <var>term</var>'s <var>suffix</var>.</li>
            <li>Otherwise, <var>term</var> is an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> or
              <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>. Set the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
              of <var>definition</var> to <var>term</var>.</li>
          </ol>
        </li>
        <li>Otherwise, if <var>active context</var> has a
          <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
          of <var>definition</var> is set to the result of concatenating the value
          associated with the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a> and <var>term</var>.
          If it does not have a <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, an
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-iri-mapping" class="internalDFN" data-link-type="dfn"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></a>
          error been detected and processing is aborted.</li>
        <li>If <var>value</var> contains the key <code>@container</code>:
          <ol>
            <li>Initialize <var>container</var> to the value associated with the
              <code>@container</code> key, which must be either
              <code class="changed">@graph</code>,
              <code class="changed">@id</code>,
              <code>@index</code>,
              <code>@language</code>,
              <code>@list</code>,
              <code>@set</code>, or
              <code>@type</code>.
              <span class="changed">
                or an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing exactly any one of those
                keywords, an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing <code>@graph</code> and
                either <code>@id</code> or <code>@index</code> optionally
                including <code>@set</code>, or an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing a
                combination of <code>@set</code> and any of
                <code>@index</code>, <code>@id</code>, <code>@type</code>,
                <code>@language</code> in any order
              </span>.
              Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-container-mapping" class="internalDFN" data-link-type="dfn"><code>invalid container mapping</code></a>
              has been detected and processing is aborted.</li>
            <li class="changed">If <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a>
              is <code>json-ld-1.0</code> and the container value
              is <code>@graph</code>, <code>@id</code>, or <code>@type</code>, or is otherwise not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-container-mapping" class="internalDFN" data-link-type="dfn"><code>invalid container mapping</code></a>
              has been detected and processing is aborted.</li>
            <li>Set the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> of <var>definition</var> to
              <var>container</var>.</li>
          </ol>
        </li>
        <li class="changed">If <var>value</var> contains the key <code>@context</code>:
          <ol>
            <li>If <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a> is <code>json-ld-1.0</code>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-term-definition" class="internalDFN" data-link-type="dfn"><code>invalid term definition</code></a>
              has been detected and processing is aborted.</li>
            <li>Initialize <var>context</var> to the value associated with the
              <code>@context</code> key, which is treated as a <var>local context</var>.</li>
            <li>Invoke the <a href="#context-processing-algorithm">Context Processing algorithm</a>
              using the <var>active context</var> and <var>context</var> as <var>local context</var>.
              If any error is detected, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-scoped-context" class="internalDFN" data-link-type="dfn"><code>invalid scoped context</code></a> error
              has been detected and processing is aborted.</li>
            <li>Set the <var>local context</var> of <var>definition</var> to <var>context</var>.</li>
          </ol>
        </li>
        <li>If <var>value</var> contains the key <code>@language</code> and
          does not contain the key <code>@type</code>:
          <ol>
            <li>Initialize <var>language</var> to the value associated with the
              <code>@language</code> key, which must be either <code>null</code>
              or a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>. Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-language-mapping" class="internalDFN" data-link-type="dfn"><code>invalid language mapping</code></a>
              error has been detected and processing is aborted.</li>
            <li>If <var>language</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> set it to
              lowercased <var>language</var>. Set the <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>
              of <var>definition</var> to <var>language</var>.</li>
          </ol>
        </li>
        <li class="changed">If <var>value</var> contains the key <code>@nest</code>:
          <ol>
            <li>If <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a> is <code>json-ld-1.0</code>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-term-definition" class="internalDFN" data-link-type="dfn"><code>invalid term definition</code></a>
              has been detected and processing is aborted.</li>
            <li>Initialize <a href="#dfn-nest-value" class="internalDFN" data-link-type="dfn">nest value</a> in <var>defined</var> to the value associated with the
              <code>@nest</code> key, which must be a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> and
              must not be a keyword other than <code>@nest</code>. Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--nest-value" class="internalDFN" data-link-type="dfn"><code>invalid @nest value</code></a>
              error has been detected and processing is aborted.</li>
          </ol>
        </li>
        <li class="changed">If <var>value</var> contains the key <code>@prefix</code>:
          <ol>
            <li>If <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a> is <code>json-ld-1.0</code>, or if
              <var>term</var> contains a colon (<code>:</code>), an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-term-definition" class="internalDFN" data-link-type="dfn"><code>invalid term definition</code></a>
              has been detected and processing is aborted.</li>
            <li>Initialize the <a href="#dfn-prefix-flag" class="internalDFN" data-link-type="dfn">prefix flag</a> to the value associated with the
              <code>@prefix</code> key, which must be a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#idl-boolean">boolean</a>. Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--prefix-value" class="internalDFN" data-link-type="dfn"><code>invalid @prefix value</code></a>
              error has been detected and processing is aborted.</li>
          </ol>
        </li>
        <li>If the value contains any key other than <code>@id</code>,
          <code>@reverse</code>, <code>@container</code>,
          <code class="changed">@context</code>, <code class="changed">@nest</code>,
          <code class="changed">@prefix</code>, or <code>@type</code>, an
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-term-definition" class="internalDFN" data-link-type="dfn"><code>invalid term definition</code></a> error has
          been detected and processing is aborted.</li>
        <li>Set the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> of <var>term</var> in
          <var>active context</var> to <var>definition</var> and set the value
          associated with <var>defined</var>'s key <var>term</var> to
          <code>true</code>.</li>
      </ol>
    </section>
  </section> <!-- end of Term Creation -->

  <section id="iri-expansion">
    <h3 id="x4-3-iri-expansion"><span class="secno">4.3 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion&nbsp;<span class="permalink"><a href="#iri-expansion" aria-label="Permalink for 4.3 IRI Expansion" title="Permalink for 4.3 IRI Expansion"><span>§</span></a></span></h3>

    <p>In JSON-LD documents, some keys and values may represent
      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a>. This section defines an algorithm for
      transforming a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> that represents an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> into
      an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.
      It also covers transforming <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword aliases</a>
      into <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a>.</p>

    <p><a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> expansion may occur during context processing or during
      any of the other JSON-LD algorithms. If <abbr title="Internationalized Resource Identifier">IRI</abbr> expansion occurs during context
      processing, then the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> and its related <var>defined</var>
      map from the <a href="#context-processing-algorithm">Context Processing algorithm</a>
      are passed to this algorithm. This allows for <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
      dependencies to be processed via the
      <a href="#create-term-definition">Create Term Definition algorithm</a>.</p>

    <section class="informative" id="overview-1">
      <h4 id="x4-3-1-overview"><span class="secno">4.3.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-1" aria-label="Permalink for 4.3.1 Overview" title="Permalink for 4.3.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>In order to expand <var>value</var> to an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, we must
        first determine if it is <code>null</code>, a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, a
        <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword alias</a>, or some form of <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. Based on what
        we find, we handle the specific kind of expansion; for example, we expand
        a <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword alias</a> to a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> and a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
        to an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> according to its <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
        in the <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>. While inspecting <var>value</var> we
        may also find that we need to create <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
        dependencies because we're running this algorithm during context processing.
        We can tell whether or not we're running during context processing by
        checking <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> against <code>null</code>.
        We know we need to create a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in the
        <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> when <var>value</var> is
        a key in the <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> and the <var>defined</var> map
        does not have a key for <var>value</var> with an associated value of
        <code>true</code>. The <var>defined</var> map is used during
        <a href="#context-processing-algorithm">Context Processing</a> to keep track of
        which <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> have already been defined or are
        in the process of being defined. We create a
        <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> by using the
        <a href="#create-term-definition">Create Term Definition algorithm</a>.</p>
    </section>

    <section id="algorithm-1">
      <h4 id="x4-3-2-algorithm"><span class="secno">4.3.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-1" aria-label="Permalink for 4.3.2 Algorithm" title="Permalink for 4.3.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes two required and four optional input variables. The
        required inputs are an <var>active context</var> and a <var>value</var>
        to be expanded. The optional inputs are two flags,
        <var>document relative</var> and <var>vocab</var>, that specifying
        whether <var>value</var> can be interpreted as a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        against the document's base <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or the
        <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a>
        <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, respectively, and
        a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> and a map <var>defined</var> to be used when
        this algorithm is used during <a href="#context-processing-algorithm">Context Processing</a>.
        If not passed, the two flags are set to <code>false</code> and
        <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> and <var>defined</var> are initialized to <code>null</code>.</p>

      <ol>
        <li>If <var>value</var> is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> or <code>null</code>,
          return <var>value</var> as is.</li>
        <li>If <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> is not <code>null</code>, it contains
          a key that equals <var>value</var>, and the value associated with the key
          that equals <var>value</var> in <var>defined</var> is not <code>true</code>,
          invoke the <a href="#create-term-definition">Create Term Definition algorithm</a>,
          passing <var>active context</var>, <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>,
          <var>value</var> as <var>term</var>, and <var>defined</var>. This will ensure that
          a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> is created for <var>value</var> in
          <var>active context</var> during <a href="#context-processing-algorithm">Context Processing</a>.
        </li>
        <li class="changed">If <var>active context</var> has a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for
          <var>value</var>, and the associated <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>,
          return that <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>.</li>
        <li>If <var>vocab</var> is <code>true</code> and the
          <var>active context</var> has a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for
          <var>value</var>, return the associated <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>.</li>
        <li>If <var>value</var> contains a colon (<code>:</code>), it is either
          an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or a
          <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>:
          <ol>
            <li>Split <var>value</var> into a <var>prefix</var> and <var>suffix</var>
              at the first occurrence of a colon (<code>:</code>).</li>
            <li>If <var>prefix</var> is underscore (<code>_</code>)
              or <var>suffix</var> begins with double-forward-slash
              (<code>//</code>), return <var>value</var> as it is already an
              <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> or a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.</li>
            <li>If <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> is not <code>null</code>, it
              contains a key that equals <var>prefix</var>, and the value
              associated with the key that equals <var>prefix</var> in <var>defined</var>
              is not <code>true</code>, invoke the
              <a href="#create-term-definition">Create Term Definition algorithm</a>,
              passing <var>active context</var>,
              <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, <var>prefix</var> as <var>term</var>,
              and <var>defined</var>. This will ensure that a
              <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> is created for <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a>
              in <var>active context</var> during
              <a href="#context-processing-algorithm">Context Processing</a>.</li>
            <li>If <var>active context</var> contains a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
              for <var>prefix</var>, return the result of concatenating
              the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> associated with <var>prefix</var> and
              <var>suffix</var>.</li>
            <li>Return <var>value</var> as it is already an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</li>
          </ol>
        </li>
        <li>If <var>vocab</var> is <code>true</code>, and
          <var>active context</var> has a <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>,
          return the result of concatenating the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>
          with <var>value</var>.</li>
        <li>Otherwise, if <var>document relative</var> is <code>true</code>
          set <var>value</var> to the result of resolving <var>value</var> against
          the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>. Only the basic algorithm in
          <a href="https://tools.ietf.org/html/rfc3986#section-5.2">section 5.2</a>
          of [<cite><a class="bibref" href="#bib-RFC3986">RFC3986</a></cite>] is used; neither
          <a href="https://tools.ietf.org/html/rfc3986#section-6.2.2">Syntax-Based Normalization</a> nor
          <a href="https://tools.ietf.org/html/rfc3986#section-6.2.3">Scheme-Based Normalization</a>
          are performed. Characters additionally allowed in <abbr title="Internationalized Resource Identifier">IRI</abbr> references are treated
          in the same way that unreserved characters are treated in URI references, per
          <a href="https://tools.ietf.org/html/rfc3987#section-6.5">section 6.5</a>
          of [<cite><a class="bibref" href="#bib-RFC3987">RFC3987</a></cite>].</li>
        <li>Return <var>value</var> as is.</li>
      </ol>
    </section>
  </section> <!-- end of IRI Expansion -->
</section> <!-- end of Context Processing section -->


<section id="expansion-algorithms">
  <!--OddPage--><h2 id="x5-expansion-algorithms"><span class="secno">5. </span>Expansion Algorithms&nbsp;<span class="permalink"><a href="#expansion-algorithms" aria-label="Permalink for 5. Expansion Algorithms" title="Permalink for 5. Expansion Algorithms"><span>§</span></a></span></h2>

  <section id="expansion-algorithm">
    <h3 id="x5-1-expansion-algorithm"><span class="secno">5.1 </span>Expansion Algorithm&nbsp;<span class="permalink"><a href="#expansion-algorithm" aria-label="Permalink for 5.1 Expansion Algorithm" title="Permalink for 5.1 Expansion Algorithm"><span>§</span></a></span></h3>

    <p>This algorithm expands a JSON-LD document, such that all <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>
      definitions are removed, all <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> and
      <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a> are expanded to
      <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute IRIs</a>,
      <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>, or
      <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> and all
      <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a> are expressed in
      <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a> in <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a>.</p>

    <section class="informative" id="overview-2">
      <h4 id="x5-1-1-overview"><span class="secno">5.1.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-2" aria-label="Permalink for 5.1.1 Overview" title="Permalink for 5.1.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>Starting with its root <var>element</var>, we can process the
        JSON-LD document recursively, until we have a fully
        <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expanded</a> <var>result</var>. When
        <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expanding</a> an <var>element</var>, we can treat
        each one differently according to its type, in order to break down the
        problem:</p>

      <ol>
        <li>If the <var>element</var> is <code>null</code>, there is nothing
          to expand.</li>
        <li>Otherwise, if <var>element</var> is a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a>, we expand it
          according to the <a href="#value-expansion">Value Expansion algorithm</a>.</li>
        <li>Otherwise, if the <var>element</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then we expand
          each of its items recursively and return them in a new
          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
        <li>Otherwise, <var>element</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. We expand
          each of its keys, adding them to our <var>result</var>, and then we expand
          each value for each key recursively. Some of the keys will be
          <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> or
          <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a> and others will be
          <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> or simply ignored because
          they do not have definitions in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>. Any
          <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> will be expanded using the
          <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>.
        </li>
      </ol>

      <p>Finally, after ensuring <var>result</var> is in an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
        we return <var>result</var>.</p>
    </section>

    <section class="algorithm" id="algorithm-2">
      <h4 id="x5-1-2-algorithm"><span class="secno">5.1.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-2" aria-label="Permalink for 5.1.2 Algorithm" title="Permalink for 5.1.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes three required <span class="changed">and one optional</span> input variables.
        The required inputs are an <var>active context</var>,
        an <var>active property</var>, and an <var>element</var> to be expanded.
        <span class="changed">The optional input is the flag <var>frame expansion</var> the allows
          special forms of input used for <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/#dfn-framing">frame expansion</a></span>.
        To begin, the <var>active property</var> is set to <code>null</code>,
        and <var>element</var> is set to the <a href="#dfn-json-ld-input" class="internalDFN" data-link-type="dfn">JSON-LD input</a>.
        <span class="changed">If not passed, the <var>frame expansion</var> flag is set to <code>false</code></span>.</p>

      <p class="changed">The algorithm also performs processing steps specific to expanding
        a <a href="#dfn-json-ld-frame" class="internalDFN" data-link-type="dfn">JSON-LD Frame</a>. For a <a href="#dfn-json-ld-frame" class="internalDFN" data-link-type="dfn">frame</a>, the <code>@id</code> and
        <code>@type</code> properties can accept an array of <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> or
        an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. The properties of a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> can also
        accept an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>, or an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.
        Framing also uses additional keyword properties:
        (<code>@explicit</code>, <code>@default</code>,
        <code>@embed</code>, <code>@explicit</code>, <code>@omitDefault</code>, or
        <code>@requireAll</code>) which are preserved through expansion.
        Special processing for a <a href="#dfn-json-ld-frame" class="internalDFN" data-link-type="dfn">JSON-LD Frame</a> is invoked when the
        <var>frame expansion</var> flag is set to <code>true</code>.</p>

        <ol>
        <li>If <var>element</var> is <code>null</code>, return <code>null</code>.</li>
        <li class="changed">If <var>active property</var> is <code>@default</code>,
          set the <var>frame expansion</var> flag to <code>false</code>.</li>
        <li>If <var>element</var> is a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a>,
          <ol>
            <li>If <var>active property</var> is <code>null</code> or <code>@graph</code>,
              drop the free-floating <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a> by returning <code>null</code>.</li>
            <li>Return the result of the
              <a href="#value-expansion">Value Expansion algorithm</a>, passing the
              <var>active context</var>, <var>active property</var>, and
              <var>element</var> as <var>value</var>.</li>
          </ol>
        </li>
        <li>If <var>element</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
          <ol>
            <li>Initialize an empty array, <var>result</var>.</li>
            <li>For each <var>item</var> in <var>element</var>:
              <ol>
                <li>Initialize <var>expanded item</var> to the result of using this
                  algorithm recursively, passing <var>active context</var>,
                  <var>active property</var>, <var>item</var> as <var>element</var>,
                  <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                <li>If the <var>active property</var> is <code>@list</code> or its
                  <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> <span class="changed">includes</span> <code>@list</code>, the
                  <var>expanded item</var> must not be an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> or a
                  <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, otherwise a
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-list-of-lists" class="internalDFN" data-link-type="dfn"><code>list of lists</code></a>
                  error has been detected and processing is aborted.</li>
                <li>If <var>expanded item</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, append each
                  of its items to <var>result</var>. Otherwise, if
                  <var>expanded item</var> is not null, append it to <var>result</var>.</li>
              </ol>
            </li>
            <li>Return <var>result</var>.</li>
          </ol>
        </li>
        <li>Otherwise <var>element</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li>If <var>element</var> contains the key <code>@context</code>, set
          <var>active context</var> to the result of the
          <a href="#context-processing-algorithm">Context Processing algorithm</a>,
          passing <var>active context</var> and the value of the
          <code>@context</code> key as <var>local context</var>.</li>
        <li class="changed">For each <var>key</var>/<var>value</var> pair in <var>element</var>
          where <var>key</var> expands to <code>@type</code> using the
          <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
          passing <var>active context</var>, <var>key</var> for
          <var>value</var>, and <code>true</code> for <var>vocab</var>:
          <ol>
            <li>For each <var>term</var> which is a value of <var>value</var> ordered lexicographically,
              if <var>term</var>'s <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var>
              has a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, set <var>active context</var> to the result
              to the result of the
              <a href="#context-processing-algorithm">Context Processing algorithm</a>,
              passing <var>active context</var> and the value of the
              <var>term</var>'s <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> as <var>local context</var>.</li>
          </ol>
        </li>
        <li>Initialize an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, <var>result</var>.</li>
        <li id="alg-expand-each-key-value">For each <var>key</var> and <var>value</var> in <var>element</var>,
          ordered lexicographically by <var>key</var>:
          <ol>
            <li>If <var>key</var> is <code>@context</code>, continue to
              the next <var>key</var>.</li>
            <li>Set <var>expanded property</var> to the result of
              using the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
              passing <var>active context</var>, <var>key</var> for
              <var>value</var>, and <code>true</code> for <var>vocab</var>.</li>
            <li>If <var>expanded property</var> is <code>null</code> or it neither
              contains a colon (<code>:</code>) nor it is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>,
              drop <var>key</var> by continuing to the next <var>key</var>.</li>
            <li>If <var>expanded property</var> is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>:
              <ol>
                <li>If <var>active property</var> equals <code>@reverse</code>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-reverse-property-map" class="internalDFN" data-link-type="dfn"><code>invalid reverse property map</code></a>
                  error has been detected and processing is aborted.</li>
                <li>If <var>result</var> has already an <var>expanded property</var> member, a
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-colliding-keywords" class="internalDFN" data-link-type="dfn"><code>colliding keywords</code></a>
                  error has been detected and processing is aborted.</li>
                <li>If <var>expanded property</var> is <code>@id</code> and
                  <var>value</var> is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--id-value" class="internalDFN" data-link-type="dfn"><code>invalid @id value</code></a>
                  error has been detected and processing is aborted. Otherwise,
                  set <var>expanded value</var> to the result of using the
                  <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
                  passing <var>active context</var>, <var>value</var>, and <code>true</code>
                  for <var>document relative</var>.
                  <span class="changed">
                    When the <var>frame expansion</var> flag is set, <var>value</var>
                    may be an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, or an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of one
                    or more <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>. <var>expanded value</var> will be
                    an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of one or more of these, with <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>
                    values expanded using the <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion Algorithm</a>.</span></li>
                <li>If <var>expanded property</var> is <code>@type</code> and <var>value</var>
                  is neither a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> nor an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of
                  <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-type-value" class="internalDFN" data-link-type="dfn"><code>invalid type value</code></a>
                  error has been detected and processing is aborted. Otherwise,
                  set <var>expanded value</var> to the result of using the
                  <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, passing
                  <var>active context</var>, <code>true</code> for <var>vocab</var>,
                  and <code>true</code> for <var>document relative</var> to expand the <var>value</var>
                  or each of its items.
                  <span class="changed">
                    When the <var>frame expansion</var> flag is set, <var>value</var>
                    may also be an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</span></li>
                <li>If <var>expanded property</var> is <code>@graph</code>, set
                  <var>expanded value</var> to the result of using this algorithm
                  recursively passing <var>active context</var>, <code>@graph</code>
                  for <var>active property</var>, <var>value</var> for <var>element</var>,
                  <span class="changed">and the <var>frame expansion</var> flag</span>,
                  <span class="changed">
                    ensuring that <var>expanded value</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of one or more <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a></span>.</li>
                <li>If <var>expanded property</var> is <code>@value</code> and
                  <var>value</var> is not a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a> or <code>null</code>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-value-object-value" class="internalDFN" data-link-type="dfn"><code>invalid value object value</code></a>
                  error has been detected and processing is aborted. Otherwise,
                  set <var>expanded value</var> to <var>value</var>. If <var>expanded value</var>
                  is <code>null</code>, set the <code>@value</code>
                  member of <var>result</var> to <code>null</code> and continue with the
                  next <var>key</var> from <var>element</var>. Null values need to be preserved
                  in this case as the meaning of an <code>@type</code> member depends
                  on the existence of an <code>@value</code> member.
                  <span class="changed">
                    When the <var>frame expansion</var> flag is set, <var>value</var>
                    may also be an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> or an array of
                    <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a> values. <var>expanded value</var> will be <a href="#dfn-null" class="internalDFN" data-link-type="dfn">null</a>, or an
                    <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of one or more <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a> values.</span></li>
                <li>If <var>expanded property</var> is <code>@language</code> and
                  <var>value</var> is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-language-tagged-string" class="internalDFN" data-link-type="dfn"><code>invalid language-tagged string</code></a>
                  error has been detected and processing is aborted.
                  <span class="changed">
                    Otherwise, set <var>expanded value</var> to lowercased <var>value</var>.
                    When the <var>frame expansion</var> flag is set, <var>value</var>
                    may also be an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> or an array of zero or
                    <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>. <var>expanded value</var> will be an
                    <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of one or more <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> values converted to lower case.</span></li>
                <li>If <var>expanded property</var> is <code>@index</code> and
                  <var>value</var> is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--index-value" class="internalDFN" data-link-type="dfn"><code>invalid @index value</code></a>
                  error has been detected and processing is aborted. Otherwise,
                  set <var>expanded value</var> to <var>value</var>.</li>
                <li>If <var>expanded property</var> is <code>@list</code>:
                  <ol>
                    <li>If <var>active property</var> is <code>null</code> or
                      <code>@graph</code>, continue with the next <var>key</var>
                      from <var>element</var> to remove the free-floating list.</li>
                    <li>Otherwise, initialize <var>expanded value</var> to the result of using
                      this algorithm recursively passing <var>active context</var>,
                      <var>active property</var>, <var>value</var> for <var>element</var>,
                      <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                    <li>If <var>expanded value</var> is a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, a
                      <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-list-of-lists" class="internalDFN" data-link-type="dfn"><code>list of lists</code></a>
                      error has been detected and processing is aborted.</li>
                  </ol>
                </li>
                <li>If <var>expanded property</var> is <code>@set</code>, set
                  <var>expanded value</var> to the result of using this algorithm
                  recursively, passing <var>active context</var>,
                  <var>active property</var>, <var>value</var> for <var>element</var>,
                  <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                <li>If <var>expanded property</var> is <code>@reverse</code> and
                  <var>value</var> is not a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, an
                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--reverse-value" class="internalDFN" data-link-type="dfn"><code>invalid @reverse value</code></a>
                  error has been detected and processing is aborted. Otherwise
                  <ol>
                    <li>Initialize <var>expanded value</var> to the result of using this
                      algorithm recursively, passing <var>active context</var>,
                      <code>@reverse</code> as <var>active property</var>,
                      <var>value</var> as <var>element</var>,
                      <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                    <li>If <var>expanded value</var> contains an <code>@reverse</code> member,
                      i.e., properties that are reversed twice, execute for each of its
                      <var>property</var> and <var>item</var> the following steps:
                      <ol>
                        <li>If <var>result</var> does not have a <var>property</var> member, create
                          one and set its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                        <li>Append <var>item</var> to the value of the <var>property</var> member
                          of <var>result</var>.</li>
                      </ol>
                    </li>
                    <li>If <var>expanded value</var> contains members other than <code>@reverse</code>:
                      <ol>
                        <li>If <var>result</var> does not have an <code>@reverse</code> member, create
                          one and set its value to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
                        <li>Reference the value of the <code>@reverse</code> member in <var>result</var>
                          using the variable <var>reverse map</var>.</li>
                        <li>For each <var>property</var> and <var>items</var> in <var>expanded value</var>
                          other than <code>@reverse</code>:
                          <ol>
                            <li>For each <var>item</var> in <var>items</var>:
                              <ol>
                                <li>If <var>item</var> is a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> or <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, an
                                  <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-reverse-property-value" class="internalDFN" data-link-type="dfn"><code>invalid reverse property value</code></a>
                                  has been detected and processing is aborted.</li>
                                <li>If <var>reverse map</var> has no <var>property</var> member, create one
                                  and initialize its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                                <li>Append <var>item</var> to the value of the <var>property</var>
                                  member in <var>reverse map</var>.</li>
                              </ol>
                            </li>
                          </ol>
                        </li>
                      </ol>
                    </li>
                    <li>Continue with the next <var>key</var> from <var>element</var>.</li>
                  </ol>
                </li>
                <li class="changed">If <var>expanded property</var> is <code>@nest</code>,
                  add <var>key</var> to <var>nests</var>, initializing it to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                  if necessary.
                  Continue with the next <var>key</var> from <var>element</var>.</li>
                <li class="changed">When the <var>frame expansion</var> flag is set,
                  if <var>expanded property</var> is any other
                  framing keyword (<code>@explicit</code>, <code>@default</code>,
                  <code>@embed</code>, <code>@explicit</code>, <code>@omitDefault</code>, or
                  <code>@requireAll</code>),
                  set <var>expanded value</var> to the result of performing the
                  <a href="#expansion-algorithm">Expansion Algorithm</a>
                  recursively, passing <var>active context</var>,
                  <var>active property</var>, <var>value</var> for <var>element</var>,
                  <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                <li>Unless <var>expanded value</var> is <code>null</code>, set
                  the <var>expanded property</var> member of <var>result</var> to
                  <var>expanded value</var>.</li>
                <li>Continue with the next <var>key</var> from <var>element</var>.</li>
              </ol>
            </li>
            <li class="changed">If <var>key</var>'s <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var>
              has a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, set <var>term context</var> to the result of the
              <a href="#context-processing-algorithm">Context Processing algorithm</a>,
              passing <var>active context</var> and the value of the
              <var>key</var>'s <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> as <var>local context</var>. Otherwise,
              set <var>term context</var> to <var>active context</var>.</li>
            <li>Set <var>container mapping</var> to <var>key</var>'s <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> in
              <var class="changed">term context</var>.</li>
            <li>If <var>container mapping</var> <span class="changed">includes</span> <code>@language</code> and
              <var>value</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> then <var>value</var>
              is expanded from a <a href="#dfn-language-maps" class="internalDFN" data-link-type="dfn">language map</a>
              as follows:
              <ol>
                <li>Initialize <var>expanded value</var> to an empty
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>For each key-value pair <var>language</var>-<var>language value</var>
                  in <var>value</var>, ordered lexicographically by <var>language</var>:
                  <ol>
                    <li>If <var>language value</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      set it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only
                      <var>language value</var>.</li>
                    <li>For each <var>item</var> in <var>language value</var>:
                      <ol>
                        <li><var>item</var> must be a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>
                          <span class="changed">or <code>null</code></span>,
                          otherwise an
                          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-language-map-value" class="internalDFN" data-link-type="dfn"><code>invalid language map value</code></a>
                          error has been detected and processing is aborted.</li>
                        <li>Append a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> to
                          <var>expanded value</var> that consists of two
                          key-value pairs: (<code>@value</code>-<var>item</var>)
                          and (<code>@language</code>-lowercased
                          <var>language</var>),
                          <span class="changed">unless <var>item</var> is <code>null</code></span>.
                          <span class="changed">If <var>language</var> is <code>@none</code>,
                            or expands to <code>@none</code>, do not set the <code>@language</code> member.</span>
                      </li></ol>
                    </li>
                  </ol>
                </li>
              </ol>
            </li>
            <li>Otherwise, if <var>container mapping</var>
              <span class="changed">includes</span> <code>@index</code>,
              <span class="changed"><code>@type</code>, or <code>@id</code></span> and
              <var>value</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> then <var>value</var>
              is expanded from an map as follows:
              <ol>
                <li>Initialize <var>expanded value</var> to an empty
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>For each key-value pair <var>index</var>-<var>index value</var>
                  in <var>value</var>, ordered lexicographically by <var>index</var>:
                  <ol>
                    <li class="changed">If <var>container mapping</var> includes <code>@type</code>,
                      and <var>index</var>'s <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in
                      <var>term context</var> has a <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>, set
                      <var>map context</var> to the result of the <a href="#context-processing-algorithm">Context Processing
                      algorithm</a>, passing <var>term context</var> as <var>active context</var> and the
                      value of the <var>index</var>'s <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> as
                      <var>local context</var>. Otherwise, set <var>map context</var>
                      to <var>term context</var>.</li>
                    <li>Set <var>expanded index</var> to the result of using the
                      <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
                      passing <var>active context</var>, <var>index</var>, and <code>true</code>
                      for <var>vocab</var>.</li>
                    <li>If <var>index value</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      set it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only
                      <var>index value</var>.</li>
                    <li>Initialize <var>index value</var> to the result of
                      using this algorithm recursively, passing
                      <var class="changed">map context</var> as <var>active context</var>,
                      <var>key</var> as <var>active property</var>,
                      <var>index value</var> as <var>element</var>,
                      <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
                    <li>For each <var>item</var> in <var>index value</var>:
                      <ol class="algorithm changed">
                        <li>If <var>container mapping</var> includes
                          <code>@graph</code> and if <var>item</var> is not a
                          <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>, set <var>item</var> to a new
                          <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing the key-value pair
                          <code>@graph</code>-<var>item</var>, ensuring that the
                          value is represented using an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                        <li>If <var>container mapping</var> includes <code>@index</code>
                          and <var>item</var> does not have the key
                          <code>@index</code> and <var>expanded index</var> is not <code>@none</code>,
                          add the key-value pair
                          (<code>@index</code>-<var>index</var>) to <var>item</var>.</li>
                        <li>Otherwise, if <var>container mapping</var> includes <code>@id</code>
                          and <var>item</var> does not have the key
                          <code>@id</code>, add the key-value pair
                          (<code>@id</code>-<var>expanded index</var>) to
                          <var>item</var>, where <var>expanded index</var> is set to the result of
                          using the
                          <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>,
                          passing <var>active context</var>, <var>index</var>, and <code>true</code>
                          for <var>document relative</var>, unless <var>expanded index</var>
                          is already set to <code>@none</code>.</li>
                        <li>Otherwise, if <var>container mapping</var> includes <code>@type</code>
                          set <var>types</var> to the concatenation of
                          <var>expanded index</var> with any existing values of
                          <code>@type</code> in <var>item</var>.
                          If <var>expanded index</var> is <code>@none</code>,
                          do not concatenate <var>expanded index</var> to <var>types</var>.
                          Add the key-value pair
                          (<code>@type</code>-<var>types</var>) to
                          <var>item</var>.</li>
                        <li>Append <var>item</var> to <var>expanded value</var>.</li>
                      </ol>
                    </li>
                  </ol>
                </li>
              </ol>
            </li>
            <li>Otherwise, initialize <var>expanded value</var> to the result of
              using this algorithm recursively, passing <var class="changed">term context</var> as <var>active context</var>,
              <var>key</var> for <var>active property</var>, <var>value</var> for <var>element</var>,
              <span class="changed">and the <var>frame expansion</var> flag</span>.</li>
            <li>If <var>expanded value</var> is <code>null</code>, ignore <var>key</var>
              by continuing to the next <var>key</var> from <var>element</var>.</li>
            <li>If <var>container mapping</var> <span class="changed">includes</span> <code>@list</code> and
              <var>expanded value</var> is not already a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>,
              convert <var>expanded value</var> to a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>
              by first setting it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only
              <var>expanded value</var> if it is not already an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
              and then by setting it to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing
              the key-value pair <code>@list</code>-<var>expanded value</var>.</li>
            <li class="changed">If <var>container mapping</var> <span>includes</span>
              <code>@graph</code>, convert <var>expanded value</var> into an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, if necessary,
              then convert each value <var>ev</var> in <var>expanded value</var> into a
              <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>:
              <ol>
                <li>If <var>ev</var> is not a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>, convert it into
                  one by creating a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing the key-value
                  pair <code>@graph</code>-<var>ev</var>
                  where <var>ev</var> is represented as an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
              </ol>
            </li><li>Otherwise, if the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> associated to
              <var>key</var> indicates that it is a <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a>
              <ol>
                <li>If <var>result</var> has no <code>@reverse</code> member, create
                  one and initialize its value to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
                <li>Reference the value of the <code>@reverse</code> member in <var>result</var>
                  using the variable <var>reverse map</var>.</li>
                <li>If <var>expanded value</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, set
                  it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing <var>expanded value</var>.</li>
                <li>For each <var>item</var> in <var>expanded value</var>
                  <ol>
                    <li>If <var>item</var> is a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> or <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, an
                      <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-reverse-property-value" class="internalDFN" data-link-type="dfn"><code>invalid reverse property value</code></a>
                      has been detected and processing is aborted.</li>
                    <li>If <var>reverse map</var> has no <var>expanded property</var> member,
                      create one and initialize its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                    <li>Append <var>item</var> to the value of the <var>expanded property</var>
                      member of <var>reverse map</var>.</li>
                  </ol>
                </li>
              </ol>
            </li>
            <li>Otherwise, if <var>key</var> is not a <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a>:
              <ol>
                <li>If <var>result</var> does not have an <var>expanded property</var>
                  member, create one and initialize its value to an empty
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>Append <var>expanded value</var> to value of the <var>expanded property</var>
                  member of <var>result</var>.</li>
              </ol>
            </li>
            <li class="changed">For each key <var>nesting-key</var> in <var>nests</var>
              <ol>
                <li>Set <var>nested values</var> to the value of <var>nesting-key</var>
                  in <var>element</var>, ensuring that it is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>For each <var>nested value</var> in <var>nested values</var>:
                  <ol>
                    <li>If <var>nested value</var> is not a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, or any key within
                      <var>nested value</var> expands to <code>@value</code>, an
                      <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--nest-value" class="internalDFN" data-link-type="dfn"><code>invalid @nest value</code></a> error
                      has been detected and processing is aborted.</li>
                    <li>Recursively repeat <a href="#alg-expand-each-key-value">step 7</a>
                      using <var>nested value</var> for <var>element</var>.</li>
                  </ol>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li>If <var>result</var> contains the key <code>@value</code>:
          <ol>
            <li>The <var>result</var> must not contain any keys other than
              <code>@value</code>, <code>@language</code>, <code>@type</code>,
              and <code>@index</code>. It must not contain both the
              <code>@language</code> key and the <code>@type</code> key.
              Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-value-object" class="internalDFN" data-link-type="dfn"><code>invalid value object</code></a>
              error has been detected and processing is aborted.</li>
            <li>If the value of <var>result</var>'s <code>@value</code> key is
              <code>null</code>, then set <var>result</var> to <code>null</code>.</li>
            <li>Otherwise, if the value of <var>result</var>'s <code>@value</code> member
              is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> and <var>result</var> contains the key
              <code>@language</code>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-language-tagged-value" class="internalDFN" data-link-type="dfn"><code>invalid language-tagged value</code></a>
              error has been detected (only <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>
              can be language-tagged) and processing is aborted.</li>
            <li>Otherwise, if the <var>result</var> has an <code>@type</code> member
              and its value is not an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-typed-value" class="internalDFN" data-link-type="dfn"><code>invalid typed value</code></a>
              error has been detected and processing is aborted.</li>
          </ol>
        </li>
        <li>Otherwise, if <var>result</var> contains the key <code>@type</code>
          and its associated value is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, set it to
          an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only the associated value.</li>
        <li>Otherwise, if <var>result</var> contains the key <code>@set</code>
          or <code>@list</code>:
          <ol>
            <li>The <var>result</var> must contain at most one other key and that
              key must be <code>@index</code>. Otherwise, an
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid-set-or-list-object" class="internalDFN" data-link-type="dfn"><code>invalid set or list object</code></a>
              error has been detected and processing is aborted.</li>
            <li>If <var>result</var> contains the key <code>@set</code>, then
              set <var>result</var> to the key's associated value.</li>
          </ol>
        </li>
        <li>If <var>result</var> contains only the key
          <code>@language</code>, set <var>result</var> to <code>null</code>.</li>
        <li>If <var>active property</var> is <code>null</code> or <code>@graph</code>,
          drop free-floating values as follows:
          <ol>
            <li>If <var>result</var> is an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> or contains
              the keys <code>@value</code> or <code>@list</code>, set <var>result</var> to
              <code>null</code>.</li>
            <li>Otherwise, if <var>result</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> whose only
              key is <code>@id</code>, set <var>result</var> to <code>null</code>.
              <span class="changed">
                When the <var>frame expansion</var> flag is set, a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
                containing only the <code>@id</code> key is retained.</span></li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>

      <p>If, after the above algorithm is run, the result is a
        <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> that contains only an <code>@graph</code> key, set the
        result to the value of <code>@graph</code>'s value. Otherwise, if the result
        is <code>null</code>, set it to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Finally, if
        the result is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set the result to an
        <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only the result.</p>
    </section>
  </section> <!-- end of Expansion Algorithm -->


  <section id="value-expansion">
    <h3 id="x5-2-value-expansion"><span class="secno">5.2 </span>Value Expansion&nbsp;<span class="permalink"><a href="#value-expansion" aria-label="Permalink for 5.2 Value Expansion" title="Permalink for 5.2 Value Expansion"><span>§</span></a></span></h3>

    <p>Some values in JSON-LD can be expressed in a
      <a href="#dfn-compact-form" class="internalDFN" data-link-type="dfn">compact form</a>. These values are required
      to be <a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">expanded</a> at times when processing
      JSON-LD documents. A value is said to be in <dfn data-dfn-type="dfn" id="dfn-expanded-form">expanded form</dfn>
      after the application of this algorithm.</p>

    <section class="informative" id="overview-3">
      <h4 id="x5-2-1-overview"><span class="secno">5.2.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-3" aria-label="Permalink for 5.2.1 Overview" title="Permalink for 5.2.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>If <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> has a <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> in the
        <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> set to <code>@id</code> or <code>@vocab</code>,
        <span class="changed">and the value is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,</span>
        a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with a single member <code>@id</code> whose
        value is the result of using the
        <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a> on <var>value</var>
        is returned.</p>

      <p>Otherwise, the result will be a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing
        an <code>@value</code> member whose value is the passed <var>value</var>.
        Additionally, an <code>@type</code> member will be included if there is a
        <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> associated with the <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a>
        or an <code>@language</code> member if <var>value</var> is a
        <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> and there is <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> associated
        with the <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a>.</p>

      <p>Note that values interpreted as <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> fall into two categories:
        those that are <var>document relative</var>, and those that are
        <em>vocabulary relative</em>. Properties and values of <code>@type</code>,
        along with terms marked as <code>"@type": "@vocab"</code>
        are <em>vocabulary relative</em>, meaning that they need to be either
        a defined <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        where the <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a> is a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>,
        or a string which is turned into an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> using
        the <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-3">
      <h4 id="x5-2-2-algorithm"><span class="secno">5.2.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-3" aria-label="Permalink for 5.2.2 Algorithm" title="Permalink for 5.2.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes three required inputs: an <var>active context</var>,
        an <var>active property</var>, and a <var>value</var> to expand.</p>

      <ol>
        <li>If the <var>active property</var> has a <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>
          in <var>active context</var> that is <code>@id</code>,
          <span class="changed">and the <var>value</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,</span>
          return a new
          <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing a single key-value pair where the
          key is <code>@id</code> and the value is the result of using the
          <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, passing
          <var>active context</var>, <var>value</var>, and <code>true</code> for
          <var>document relative</var>.</li>
        <li>If <var>active property</var> has a <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> in
          <var>active context</var> that is <code>@vocab</code>,
          <span class="changed">and the <var>value</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,</span>
          return a new
          <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing a single key-value pair where the
          key is <code>@id</code> and the value is the result of using the
          <a href="#iri-expansion"><abbr title="Internationalized Resource Identifier">IRI</abbr> Expansion algorithm</a>, passing
          <var>active context</var>, <var>value</var>, <code>true</code> for
          <var>vocab</var>, and <code>true</code> for
          <var>document relative</var>.</li>
        <li>Otherwise, initialize <var>result</var> to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
          with an <code>@value</code> member whose value is set to
          <var>value</var>.</li>
        <li>If <var>active property</var> has a <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> in
          <var>active context</var>,
          <span class="changed">other than <code>@id</code> or <code>@vocab</code>,</span>
          add an <code>@type</code> member to
          <var>result</var> and set its value to the value associated with the
          <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>.</li>
        <li>Otherwise, if <var>value</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>:
          <ol>
            <li>If a <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> is associated with
              <var>active property</var> in <var>active context</var>,
              add an <code>@language</code> to <var>result</var> and set its
              value to the language code associated with the
              <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>; unless the
              <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> is set to <code>null</code> in
              which case no member is added.</li>
            <li>Otherwise, if the <var>active context</var> has a
              <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>, add an <code>@language</code>
              to <var>result</var> and set its value to the
              <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>.</li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Value Expansion -->

</section> <!-- end of Expansion section -->


<section id="compaction-algorithms">
  <!--OddPage--><h2 id="x6-compaction-algorithms"><span class="secno">6. </span>Compaction Algorithms&nbsp;<span class="permalink"><a href="#compaction-algorithms" aria-label="Permalink for 6. Compaction Algorithms" title="Permalink for 6. Compaction Algorithms"><span>§</span></a></span></h2>

  <section id="compaction-algorithm">
    <h3 id="x6-1-compaction-algorithm"><span class="secno">6.1 </span>Compaction Algorithm&nbsp;<span class="permalink"><a href="#compaction-algorithm" aria-label="Permalink for 6.1 Compaction Algorithm" title="Permalink for 6.1 Compaction Algorithm"><span>§</span></a></span></h3>

    <p>This algorithm compacts a JSON-LD document, such that the given
      <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> is applied. This must result in shortening
      any applicable <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> to
      <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> or
      <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a>, any applicable
      <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> to
      <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword aliases</a>, and
      any applicable <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a>
      expressed in <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a> to simple values such as
      <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a> or
      <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a>.</p>

    <section class="informative" id="overview-4">
      <h4 id="x6-1-1-overview"><span class="secno">6.1.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-4" aria-label="Permalink for 6.1.1 Overview" title="Permalink for 6.1.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>Starting with its root <var>element</var>, we can process the
        JSON-LD document recursively, until we have a fully
        <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacted</a> <var>result</var>. When
        <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> an <var>element</var>, we can treat
        each one differently according to its type, in order to break down the
        problem:</p>

      <ol>
        <li>If the <var>element</var> is a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a>, it is
          already in <a href="#dfn-compact-form" class="internalDFN" data-link-type="dfn">compacted form</a>, so we simply return it.</li>
        <li>If the <var>element</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, we compact
          each of its items recursively and return them in a new
          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
        <li>Otherwise <var>element</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. The value
          of each key in element is compacted recursively. Some of the keys will be
          compacted, using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
          to <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> or <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a>
          and others will be compacted from <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> to
          <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword aliases</a> or simply left
          unchanged because they do not have definitions in the <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>.
          Values will be converted to <a href="#dfn-compact-form" class="internalDFN" data-link-type="dfn">compacted form</a> via the
          <a href="#value-compaction">Value Compaction algorithm</a>. Some data
          will be reshaped based on <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
          specified in the context such as <code>@index</code> or <code>@language</code>
          maps.</li>
      </ol>

      <p>The final output is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with an <code>@context</code>
        key, if a non-empty <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> was given, where the <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
        is either <var>result</var> or a wrapper for it where <var>result</var> appears
        as the value of an (aliased) <code>@graph</code> key because <var>result</var>
        contained two or more items in an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-4">
      <h4 id="x6-1-2-algorithm"><span class="secno">6.1.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-4" aria-label="Permalink for 6.1.2 Algorithm" title="Permalink for 6.1.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes five required input variables: an <var>active context</var>,
        an <var>inverse context</var>, an <var>active property</var>, an
        <var>element</var> to be compacted, and a flag
        <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a>
        To begin, the <var>active context</var> is set to the result of
        performing <a href="#context-processing-algorithm">Context Processing</a>
        on the passed <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a>, the <var>inverse context</var> is
        set to the result of performing the
        <a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
        on <var>active context</var>, the <var>active property</var> is
        set to <code>null</code>, <var>element</var> is set to the result of
        performing the <a href="#expansion-algorithm">Expansion algorithm</a>
        on the <a href="#dfn-json-ld-input" class="internalDFN" data-link-type="dfn">JSON-LD input</a>, and, if not passed,
        <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a>
        is set to <code>true</code>.</p>

      <ol>
        <li class="changed">If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>active property</var> has a
          <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>:
          <ol>
            <li>Set <var>active context</var> to the result of the
              <a href="#context-processing-algorithm">Context Processing algorithm</a>,
              passing <var>active context</var> and the value of the
              <var>active property</var>'s <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> as <var>local context</var>.</li>
            <li>Set <var>inverse context</var> using the
              <a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
              using <var>active context</var>.</li>
          </ol>
        </li>
        <li>If <var>element</var> is a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a>, it is already in its most
          compact form, so simply return <var>element</var>.</li>
        <li>If <var>element</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>:
          <ol>
            <li>Initialize <var>result</var> to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
            <li>For each <var>item</var> in <var>element</var>:
              <ol>
                <li>Initialize <var>compacted item</var> to the result of using this
                  algorithm recursively, passing <var>active context</var>,
                  <var>inverse context</var>, <var>active property</var>, and
                  <var>item</var> for <var>element</var>.</li>
                <li>If <var>compacted item</var> is not <code>null</code>, then append
                  it to <var>result</var>.</li>
              </ol>
            </li>
            <li>If <var>result</var> contains only one item (it has a length of
              <code>1</code>),
              <span class="changed">
                <var>active property</var> is not <code>@graph</code> or <code>@set</code>,
                or the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> for <var>active property</var> in
                <var>active context</var> does not include <code>@list</code> or <code>@set</code>,
              </span>
              and <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a>
              is <code>true</code>, set <var>result</var> to its only item.</li>
            <li>Return <var>result</var>.</li>
          </ol>
        </li>
        <li>Otherwise <var>element</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.
          If <var>element</var> has an <code>@value</code> or <code>@id</code>
          member and the result of using the
          <a href="#value-compaction">Value Compaction algorithm</a>,
          passing <var>active context</var>, <var>inverse context</var>,
          <var>active property</var>,and <var>element</var> as <var>value</var> is
          a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a>, return that result.</li>
        <li>Initialize <var>inside reverse</var> to <code>true</code> if
          <var>active property</var> equals <code>@reverse</code>,
          otherwise to <code>false</code>.</li>
        <li>Initialize <var>result</var> to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li class="changed">If <var>element</var> has a <code>@type</code> member,
          create a new array <var>compacted types</var> initialized
          by transforming each <var>expanded type</var> of that member
          into it's compacted form using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
          passing <var>active context</var>, <var>inverse context</var>,
          <var>expanded type</var> for <var>var</var>, and
          <code>true</code> for <var>vocab</var>. Then, for each <var>term</var>
          in <var>compacted types</var> ordered lexicographically:
          <ol>
            <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>term</var> has a
              <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a>:
              <ol>
                <li>Set <var>active context</var> to the result of the
                  <a href="#context-processing-algorithm">Context Processing algorithm</a>,
                  passing <var>active context</var> and the value of <var>term</var>'s
                  <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> as <var>local context</var>.</li>
                <li>Set <var>inverse context</var> using the
                  <a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
                  using <var>active context</var>.</li>
              </ol>
            </li>
          </ol>
        </li>
        <li>For each key <var>expanded property</var> and value <var>expanded value</var>
          in <var>element</var>, ordered lexicographically by <var>expanded property</var>:
          <ol>
            <li>If <var>expanded property</var> is <code>@id</code> or
              <code>@type</code>:
                <ol>
                  <li>If <var>expanded value</var> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,
                    then initialize <var>compacted value</var> to the result
                    of using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                    passing <var>active context</var>, <var>inverse context</var>,
                    <var>expanded value</var> for <var>var</var>,
                    and <code>true</code> for <var>vocab</var> if
                    <var>expanded property</var> is <code>@type</code>,
                    <code>false</code> otherwise.</li>
                  <li>Otherwise, <var>expanded value</var> must be a
                    <code>@type</code> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>:
                    <ol>
                      <li>Initialize <var>compacted value</var> to an empty
                        <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                      <li>For each item <var>expanded type</var> in
                        <var>expanded value</var>:
                        <ol>
                          <li>Set <var>term</var> to the result of
                            of using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                            passing <var>active context</var>, <var>inverse context</var>,
                            <var>expanded type</var> for <var>var</var>, and
                            <code>true</code> for <var>vocab</var>.</li>
                          <li>Append <var>term</var>, to <var>compacted value</var>.</li>
                        </ol>
                      </li>
                      <li>If <var>compacted value</var> contains only one
                        item (it has a length of <code>1</code>), then
                        set <var>compacted value</var> to its only item.</li>
                    </ol>
                  </li>
                  <li>Initialize <var>alias</var> to the result of using the
                    <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                    passing <var>active context</var>, <var>inverse context</var>,
                    <var>expanded property</var> for <var>var</var>,
                    and <code>true</code> for <var>vocab</var>.</li>
                  <li>Add a member <var>alias</var> to <var>result</var> whose value is
                    set to <var>compacted value</var> and continue to the next
                    <var>expanded property</var>.</li>
                </ol>
              </li>
            <li>If <var>expanded property</var> is <code>@reverse</code>:
              <ol>
                <li>Initialize <var>compacted value</var> to the result of using this
                  algorithm recursively, passing <var>active context</var>,
                  <var>inverse context</var>, <code>@reverse</code> for
                  <var>active property</var>, and <var>expanded value</var>
                  for <var>element</var>.</li>
                <li>For each <var>property</var> and <var>value</var> in <var>compacted value</var>:
                  <ol>
                    <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>property</var> in the
                      <var>active context</var> indicates that <var>property</var> is
                      a <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a>
                      <ol>
                        <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>property</var> in
                          the <var>active context</var> has a
                          <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> <span class="changed">including</span> <code>@set</code> or
                          <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a>
                          is <code>false</code>, and <var>value</var> is not an
                          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, set <var>value</var> to a new
                          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only <var>value</var>.</li>
                        <li>If <var>property</var> is not a member of
                          <var>result</var>, add one and set its value to <var>value</var>.</li>
                        <li>Otherwise, if the value of the <var>property</var> member of
                          <var>result</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, set it to a new
                          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only the value. Then
                          append <var>value</var> to its value if <var>value</var>
                          is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, otherwise append each
                          of its items.</li>
                        <li>Remove the <var>property</var> member from
                          <var>compacted value</var>.</li>
                      </ol>
                    </li>
                  </ol>
                </li>
                <li>If <var>compacted value</var> has some remaining members, i.e.,
                  it is not an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>:
                  <ol>
                    <li>Initialize <var>alias</var> to the result of using the
                      <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                      passing <var>active context</var>, <var>inverse context</var>,
                      <code>@reverse</code> for <var>var</var>,
                      and <code>true</code> for <var>vocab</var>.</li>
                    <li>Set the value of the <var>alias</var> member of <var>result</var> to
                      <var>compacted value</var>.</li>
                  </ol>
                </li>
                <li>Continue with the next <var>expanded property</var> from <var>element</var>.</li>
              </ol>
            </li>
            <li class="changed">If <var>expanded property</var> is <code>@preserve</code>
              then:
              <ol>
                <li>Initialize <var>compacted value</var> to the result of using this
                  algorithm recursively, passing <var>active context</var>,
                  <var>inverse context</var>, <var>property</var> for
                  <var>active property</var>, and <var>expanded value</var>
                  for <var>element</var>.</li>
                <li>Add <var>expanded value</var> as the value of <code>@preserve</code>
                  in <var>result</var> unless <var>expanded value</var> is an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
              </ol>
            </li>
            <li>If <var>expanded property</var> is <code>@index</code> and
              <var>active property</var> has a <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
              in <var>active context</var> that <span class="changed">includes</span> <code>@index</code>,
              then the compacted result will be inside of an <code>@index</code>
              container, drop the <code>@index</code> property by continuing
              to the next <var>expanded property</var>.</li>
            <li>Otherwise, if <var>expanded property</var> is <code>@index</code>,
              <code>@value</code>, or <code>@language</code>:
              <ol>
                <li>Initialize <var>alias</var> to the result of using
                  the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                  passing <var>active context</var>, <var>inverse context</var>,
                  <var>expanded property</var> for <var>var</var>,
                  and <code>true</code> for <var>vocab</var>.</li>
                <li>Add a member <var>alias</var> to <var>result</var> whose value is
                  set to <var>expanded value</var> and continue with the next
                  <var>expanded property</var>.</li>
              </ol>
            </li>
            <li>If <var>expanded value</var> is an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>:
              <ol>
                <li>Initialize <var>item active property</var> to the result of
                  using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                  passing <var>active context</var>, <var>inverse context</var>,
                  <var>expanded property</var> for <var>var</var>,
                  <var>expanded value</var> for <var>value</var>,
                  <code>true</code> for <var>vocab</var>, and
                  <var>inside reverse</var>.</li>
                <li class="changed">If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>item active property</var>
                  in the <var>active context</var> has a <a href="#dfn-nest-value" class="internalDFN" data-link-type="dfn">nest value</a>, that value (<var>nest term</var>) must be
                  <code>@nest</code>, or a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> in the
                  <var>active context</var> that expands to <code>@nest</code>,
                  otherwise an <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--nest-value" class="internalDFN" data-link-type="dfn">invalid @nest
                  value</a> error has been detected, and processing is aborted.
                  If <var>result</var> does not have the key that equals <var>nest
                  term</var>, initialize it to an empty JSON object (<var>nest
                  object</var>). If <var>nest object</var> does not have the key
                  that equals <var>item active property</var>, set this key's
                  value in <var>nest object</var> to an empty
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.Otherwise, if the key's value is not an
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set it to one containing only the
                  value.</li>
                <li>Otherwise, if <var>result</var> does not have the key that equals
                  <var>item active property</var>, set this key's value in
                  <var>result</var> to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Otherwise, if
                  the key's value is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set it
                  to one containing only the value.</li>
              </ol>
            </li>
            <li>
              At this point, <var>expanded value</var> must be an
              <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> due to the
              <a href="#expansion-algorithm">Expansion algorithm</a>.
              For each item <var>expanded item</var> in <var>expanded value</var>:
              <ol>
                <li>Initialize <var>item active property</var> to the result of using
                  the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                  passing <var>active context</var>, <var>inverse context</var>,
                  <var>expanded property</var> for <var>var</var>,
                  <var>expanded item</var> for <var>value</var>,
                  <code>true</code> for <var>vocab</var>, and
                  <var>inside reverse</var>.</li>
                <li class="changed">If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> for <var>item active property</var>
                  in the <var>active context</var> has a <a href="#dfn-nest-value" class="internalDFN" data-link-type="dfn">nest value</a>
                  member, that value (<var>nest term</var>) must be
                  <code>@nest</code>, or a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> in the
                  <var>active context</var> that expands to <code>@nest</code>,
                  otherwise an <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-invalid--nest-value" class="internalDFN" data-link-type="dfn">invalid @nest
                  value</a> error has been detected, and processing is aborted.
                  Set <var>nest result</var> to the value of <var>nest term</var> in <var>result</var>,
                  initializing it to a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, if necessary; otherwise
                  set <var>nest result</var> to <var>result</var>.</li>
                <li>Initialize <var>container</var> to <code>null</code>. If there
                  is a <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> for
                  <var>item active property</var> in <var>active context</var>,
                  set <var>container</var> to <span class="changed">the first</span>
                  such value <span class="changed">other than <code>@set</code></span>.</li>
                <li class="changed">Initialize <var>as array</var> to
                  <code>true</code> or <code>false</code> depending on if the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> for
                  <var>item active property</var> in <var>active context</var>
                  includes <code>@set</code> or if <var>item active property</var>
                  is <code>@graph</code> or <code>@list</code>.</li>
                <li>Initialize <var>compacted item</var> to the result of using
                  this algorithm recursively, passing
                  <var>active context</var>, <var>inverse context</var>,
                  <var>item active property</var> for <var>active property</var>,
                  <var>expanded item</var> for <var>element</var> if it does
                  not contain the key <code>@list</code>
                  <span class="changed">and is not a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a> containing <code>@list</code></span>,
                  otherwise pass the key's associated value for <var>element</var>.</li>
                <li>
                  If <var>expanded item</var> is a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>:
                  <ol>
                    <li>If <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                      then set it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only
                      <var>compacted item</var>.</li>
                    <li>If <var>container</var> is not <code>@list</code>:
                      <ol>
                        <li>Convert <var>compacted item</var> to a
                          <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a> by setting it to a
                          <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing key-value pair
                          where the key is the result of the
                          <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                          passing <var>active context</var>, <var>inverse context</var>,
                          <code>@list</code> for <var>var</var>, and <var>compacted item</var>
                          for <var>value</var> and the value is the original <var>compacted item</var>.</li>
                        <li>If <var>expanded item</var> contains the key
                          <code>@index</code>, then add a key-value pair
                          to <var>compacted item</var> where the key is the
                          result of the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
                          passing <var>active context</var>, <var>inverse context</var>,
                          <code>@index</code> as <var>var</var>, and the value associated with the
                          <code>@index</code> key in <var>expanded item</var> as <var>value</var>.</li>
                      </ol>
                    </li>
                    <li>Otherwise, <var>item active property</var> must not be a key
                      in <var class="changed">nest result</var> because there cannot be two
                      <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list objects</a> associated
                      with an <var>active property</var> that has a
                      <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>; a
                      <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-compaction-to-list-of-lists" class="internalDFN" data-link-type="dfn"><code>compaction to list of lists</code></a>
                      error has been detected and processing is aborted.</li>
                  </ol>
                </li>
                <li class="changed">
                  If <var>expanded item</var> is a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>:
                  <ol>
                    <li>If <var>container</var> includes <code>@graph</code> and <code>@id</code>:
                      <ol>
                        <li>Initialize <var>map object</var> to the value of <var>item active property</var>
                          in <var class="changed">nest result</var>.</li>
                        <li>Initialize <var>map key</var> to the result of calling the
                          <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                          passing <var>active context</var> and the value of <code>@id</code> in <var>expanded item</var>
                          or <code>@none</code> if no such value exists as <var>var</var>, with <var>vocab</var> set to <code>true</code>
                          if there is no <code>@id</code> member in <var>expanded item</var>.</li>
                        <li class="changed">If <var>compacted item</var> is not an
                          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> and <var>as array</var> is <code>true</code>,
                          set <var>compacted item</var> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing that value.</li>
                        <li>If <var>map key</var> is not a key in <var>map object</var>,
                          then set this key's value in <var>map object</var>
                          to <var>compacted item</var>. Otherwise, if the value
                          is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set it to one
                          containing only the value and then append
                          <var>compacted item</var> to it.</li>
                      </ol>
                    </li>
                    <li>Otherwise, if <var>container</var> includes <code>@graph</code> and <code>@index</code>
                      and <var>expanded item</var> is a <a href="#dfn-simple-graph-objects" class="internalDFN" data-link-type="dfn">simple graph object</a>:
                      <ol>
                        <li>Initialize <var>map object</var> to the value of <var>item active property</var>
                          in <var class="changed">nest result</var>.</li>
                        <li>Initialize <var>map key</var> the value of <code>@index</code> in
                          <var>expanded item</var> or <code>@none</code>, if no such
                          value exists.</li>
                        <li class="changed">If <var>compacted item</var> is not an
                          <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> and <var>as array</var> is <code>true</code>,
                          set <var>compacted item</var> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing that value.</li>
                        <li>If <var>map key</var> is not a key in <var>map object</var>,
                          then set this key's value in <var>map object</var>
                          to <var>compacted item</var>. Otherwise, if the value
                          is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set it to one
                          containing only the value and then append
                          <var>compacted item</var> to it.</li>
                      </ol>
                    </li>
                    <li>Otherwise, if <var>container</var> includes <code>@graph</code>
                      and <var>expanded item</var> is a <a href="#dfn-simple-graph-objects" class="internalDFN" data-link-type="dfn">simple graph
                      object</a> the value cannot be represented as a map
                      object. If <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      and <var>as array</var> is <code>true</code>, set
                      <var>compacted item</var> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing
                      that value. If the value associated with the key that
                      equals <var>item active property</var> in
                      <var class="changed">nest result</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                      set it to a new <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only the value.
                      Then append <var>compacted item</var> to the value if
                      <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                      otherwise, concatenate it.
                    </li>
                    <li>Otherwise, <var>container</var> does not include <code>@graph</code>
                      or otherwise does not match one of the previous cases, redo <var>compacted item</var>.
                      <ol>
                        <li>Set <var>compacted item</var> to a new dictionary containing
                          the key resulting from calling the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                          passing <var>active context</var>, <code>@graph</code> as
                          <var>var</var>, and <code>true</code> for
                          <var>vocab</var> using the original
                          <var>compacted item</var> as a value.</li>
                        <li>If expanded item contains the key <code>@id</code>,
                          add the key resulting from calling the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                          passing <var>active context</var>, <code>@id</code> as
                          <var>var</var>, and <code>true</code> for
                          <var>vocab</var> using the value resulting from calling the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                          passing <var>active context</var>, the value of <code>@id</code>
                          in <var>expanded item</var> as
                          <var>var</var>.</li>
                        <li>If expanded item contains the key <code>@index</code>,
                          add the key resulting from calling the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                          passing <var>active context</var>, <code>@index</code> as
                          <var>var</var>, and <code>true</code> for
                          <var>vocab</var> using the value of <code>@index</code>
                          in <var>expanded item</var>.</li>
                        <li>If <var>as array</var> is <code>true</code>,
                          set <var>compacted item</var> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                          containing that value.</li>
                        <li>Then append <var>compacted item</var> to the value if
                          <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                          otherwise, concatenate it.</li>
                      </ol>
                    </li>
                  </ol>
                </li>
                <li>
                  <span class="changed">Otherwise</span>, if <var>container</var> <span class="changed">includes</span> <code>@language</code>,
                  <code>@index</code>, <span class="changed"><code>@id</code>,
                    or <code>@type</code></span>
                    <span class="changed">and <var>container</var> does not include <code>@graph</code></span>:
                  <ol>
                    <li>If <var>item active property</var> is not a key in
                      <var class="changed">nest result</var>, initialize it to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.
                      Initialize <var>map object</var> to the value of <var>item active property</var>
                      in <var class="changed">nest result</var>.</li>
                    <li>Set <var>container key</var> to the result of calling the
                      <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                      passing <var>active context</var>,
                      either <code>@language</code>, <code>@index</code>, <code>@id</code>, or <code>@type</code>
                      based on the contents of <var>container</var>, as <var>var</var>, and <code>true</code>
                      for <var>vocab</var>.</li>
                    <li>If <var>container</var> includes <code>@language</code> and
                      <var>expanded item</var> contains the key
                      <code>@value</code>, then set <var>compacted item</var>
                      to the value associated with its <code>@value</code> key.
                      Set <var>map key</var> to the value of <code>@language</code> in <var>expanded item</var>, if any.</li>
                    <li>If <var>container</var> includes <code>@index</code> set <var>map key</var> to the value of <code>@index</code> in <var>expanded item</var>, if any,
                      and remove <var>container key</var> from <var>compacted item</var>.</li>
                    <li class="changed">If <var>container</var> includes <code>@id</code>, set
                      <var>map key</var> to the value of <var>container key</var> in
                      <var>compacted item</var> and remove <var>container key</var> from <var>compacted item</var>.</li>
                    <li class="changed">If <var>container</var> is <code>@type</code>,
                      set <var>map key</var> to the first value of <var>container key</var> in <var>compacted item</var>, if any.
                      If there are remaining values in <var>compacted item</var>
                      for <var>compacted container</var>, set the value of
                      <var>compacted container</var> in <var>compacted value</var>
                      to those remaining values. Otherwise, remove that
                      key-value pair from <var>compacted item</var>.</li>
                    <li class="changed">If <var>compacted item</var> is not an
                      <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> and <var>as array</var> is <code>true</code>,
                      set <var>compacted item</var> to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing that value.</li>
                    <li>If <var>map key</var> is <code>null</code>, set it to the result of calling the
                      <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
                      passing <var>active context</var>, <code>@none</code> as
                      <var>var</var>, and <code>true</code> for
                      <var>vocab</var>.</li>
                    <li>If <var>map key</var> is not a key in <var>map object</var>,
                      then set this key's value in <var>map object</var>
                      to <var>compacted item</var>. Otherwise, if the value
                      is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, then set it to one
                      containing only the value and then append
                      <var>compacted item</var> to it.</li>
                  </ol>
                </li>
                <li>
                  Otherwise,
                  <ol>
                    <li>If
                      <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a>
                      is <code>false</code>, <var>as array</var> is <code>true</code> and
                      <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                      set it to a new <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      containing only <var>compacted item</var>.</li>
                    <li>If <var>item active property</var> is not a key in
                      <var>result</var> then add the key-value pair,
                      (<var>item active property</var>-<var>compacted item</var>),
                      to <var class="changed">nest result</var>.</li>
                    <li>Otherwise, if the value associated with the key that
                      equals <var>item active property</var> in <var class="changed">nest result</var>
                      is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, set it to a new
                      <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing only the value. Then
                      append <var>compacted item</var> to the value if
                      <var>compacted item</var> is not an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>,
                      otherwise, concatenate it.</li>
                  </ol>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>

      <p>If, after the algorithm outlined above is run, <var>result</var>
        <span class="changed">is an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, replace it with a new <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a></span>.
        Otherwise, if <var>result</var> is an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>, replace it with a new
        <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with a single member whose key is the result
        of using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
        passing <var>active context</var>, <var>inverse context</var>, and
        <code>@graph</code> as <var>var</var> and whose value is the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
        <var>result</var>.</p>
      <p>Finally, if a non-empty <var>context</var> has been passed,
        add an <code>@context</code> member to <var>result</var> and set its value
        to the passed <var>context</var>.</p>
    </section>
  </section> <!-- end of Compaction -->

  <section id="inverse-context-creation">
    <h3 id="x6-2-inverse-context-creation"><span class="secno">6.2 </span>Inverse Context Creation&nbsp;<span class="permalink"><a href="#inverse-context-creation" aria-label="Permalink for 6.2 Inverse Context Creation" title="Permalink for 6.2 Inverse Context Creation"><span>§</span></a></span></h3>

    <p>When there is more than one <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that could be chosen
      to compact an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, it has to be ensured that the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
      selection is both deterministic and represents the most context-appropriate
      choice whilst taking into consideration algorithmic complexity.</p>

    <p>In order to make <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> selections, the concept of an
      <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> is introduced. An <dfn data-dfn-type="dfn" id="dfn-inverse-context">inverse context</dfn>
      is essentially a reverse lookup table that maps
      <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>,
      <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mappings</a>, and
      <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mappings</a> to a simple
      <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> for a given <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>. A
      <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> only needs to be generated for an
      <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> if it is being used for <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compaction</a>.</p>

    <p>To make use of an <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a>, a list of preferred
      <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> and the
      <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> are gathered
      for a particular value associated with an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. These parameters
      are then fed to the <a href="#term-selection">Term Selection algorithm</a>,
      which will find the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that most appropriately
      matches the value's mappings.</p>

    <section class="informative" id="overview-5">
      <h4 id="x6-2-1-overview"><span class="secno">6.2.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-5" aria-label="Permalink for 6.2.1 Overview" title="Permalink for 6.2.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>To create an <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> for a given
        <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>, each <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> in the
        <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> is visited, ordered by length, shortest
        first (ties are broken by choosing the lexicographically least
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>). For each <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, an entry is added to
        the <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> for each possible combination of
        <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> and <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>
        or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> that would legally match the
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>. Illegal matches include differences between a
        value's <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> and
        that of the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>. If a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> has no
        <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>, <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>, or
        <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> (or some combination of these), then it
        will have an entry in the <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> using the special
        key <code>@none</code>. This allows the
        <a href="#term-selection">Term Selection algorithm</a> to fall back
        to choosing more generic <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> when a more
        specifically-matching <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> is not available for a particular
        <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> and value combination.</p>
    </section>

    <section class="algorithm" id="algorithm-5">
      <h4 id="x6-2-2-algorithm"><span class="secno">6.2.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-5" aria-label="Permalink for 6.2.2 Algorithm" title="Permalink for 6.2.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes one required input: the <var>active context</var> that
        the <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> is being created for.</p>

      <ol>
        <li>Initialize <var>result</var> to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li>Initialize <var>default language</var> to <code>@none</code>. If the
          <var>active context</var> has a <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>,
          set <var>default language</var> to it.</li>
        <li>For each key <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> and value <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in
          the <var>active context</var>, ordered by shortest <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
          first (breaking ties by choosing the lexicographically least
          <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>):
          <ol>
            <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> is <code>null</code>,
              <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> cannot be selected during <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compaction</a>,
              so continue to the next <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>.</li>
            <li>Initialize <var>container</var> to <code>@none</code>.
              <span class="changed">
                If the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> is not empty, set <var>container</var>
                to the concatenation of all values of the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
                in lexicographically order
              </span>.</li>
            <li>Initialize <var>var</var> to the value of the <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
              for the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>.</li>
            <li>If <var>var</var> is not a key in <var>result</var>, add
              a key-value pair where the key is <var>var</var> and the value
              is an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> to <var>result</var>.</li>
            <li>Reference the value associated with the <var>var</var> member in
              <var>result</var> using the variable <var>container map</var>.</li>
            <li>If <var>container map</var> has no <var>container</var> member,
              create one and set its value to a new
              <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with <span class="changed">three</span> members.
              The first member is <code>@language</code> and its value is a new empty
              <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, the second member is <code>@type</code>
              and its value is a new empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>,
              <span class="changed">and the third member is <code>@any</code>
                and its value is a new <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with the member
                <code>@none</code> set to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> being processed</span>.</li>
            <li>Reference the value associated with the <var>container</var> member
              in <var>container map</var> using the variable <var>type/language map</var>.</li>
            <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> indicates that the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
              represents a <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a>:
              <ol>
                <li>Reference the value associated with the <code>@type</code>
                  member in <var>type/language map</var> using the variable
                  <var>type map</var>.</li>
                <li>If <var>type map</var> does not have an <code>@reverse</code>
                  member, create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
              </ol>
            </li>
            <li>Otherwise, if <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> has a
              <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>:
              <ol>
                <li>Reference the value associated with the <code>@type</code>
                  member in <var>type/language map</var> using the variable
                  <var>type map</var>.</li>
                <li>If <var>type map</var> does not have a member corresponding
                  to the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> in <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>,
                  create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
              </ol>
            </li>
            <li>Otherwise, if <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> has a
              <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> (might be <code>null</code>):
              <ol>
                <li>Reference the value associated with the <code>@language</code>
                  member in <var>type/language map</var> using the variable
                  <var>language map</var>.</li>
                <li>If the <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> equals <code>null</code>,
                  set <var>language</var> to <code>@null</code>; otherwise set it
                  to the language code in <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>.</li>
                <li>If <var>language map</var> does not have a <var>language</var> member,
                  create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
              </ol>
            </li>
            <li>Otherwise:
              <ol>
                <li>Reference the value associated with the <code>@language</code>
                  member in <var>type/language map</var> using the variable
                  <var>language map</var>.</li>
                <li>If <var>language map</var> does not have a <var>default language</var>
                  member, create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
                <li>If <var>language map</var> does not have an <code>@none</code>
                  member, create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
                <li>Reference the value associated with the <code>@type</code>
                  member in <var>type/language map</var> using the variable
                  <var>type map</var>.</li>
                <li>If <var>type map</var> does not have an <code>@none</code>
                  member, create one and set its value to the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
                  being processed.</li>
              </ol>
            </li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Inverse Context Creation -->

  <section id="iri-compaction">
    <h3 id="x6-3-iri-compaction"><span class="secno">6.3 </span><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction&nbsp;<span class="permalink"><a href="#iri-compaction" aria-label="Permalink for 6.3 IRI Compaction" title="Permalink for 6.3 IRI Compaction"><span>§</span></a></span></h3>

    <p>This algorithm compacts an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> to a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> or
      <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> to a
      <a href="#dfn-keyword-aliases" class="internalDFN" data-link-type="dfn">keyword alias</a>. A value that is associated with the
      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> may be passed in order to assist in selecting the most
      context-appropriate <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>.</p>

    <section class="informative" id="overview-6">
      <h4 id="x6-3-1-overview"><span class="secno">6.3.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-6" aria-label="Permalink for 6.3.1 Overview" title="Permalink for 6.3.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>If the passed <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> is <code>null</code>, we simply
        return <code>null</code>. Otherwise, we first try to find a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
        that the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> can be compacted to if
        it is relative to <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a>
        <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>. In order to select the most appropriate
        <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, we may have to collect information about the passed
        <var>value</var>. This information includes which
        <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
        would be preferred for expressing the <var>value</var>, and what its
        <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> is. For
        <a data-lt="list object" href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">JSON-LD lists</a>, the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>
        or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> will be chosen based on the most
        specific values that work for all items in the list. Once this
        information is gathered, it is passed to the
        <a href="#term-selection">Term Selection algorithm</a>, which will
        return the most appropriate <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> to use.</p>

      <p>If no <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> was found that could be used to compact the
        <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, an attempt is made to compact the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> using the
        <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a> <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>,
        if there is one. If the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> could not be compacted, an
        attempt is made to find a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.
        <span class="changed">A term will be used to create a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
          only if the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> contains the <a href="#dfn-prefix-flag" class="internalDFN" data-link-type="dfn">prefix flag</a>
          with the value <code>true</code>.</span>
        If there is no appropriate <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
        <span class="changed">and the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a> option is <code>true</code>,</span>
        the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> is
        transformed to a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> using the document's
        <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>. Finally, if the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or
        <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> still could not be compacted, it is returned
        as is.</p>
    </section>

    <section class="algorithm" id="algorithm-6">
      <h4 id="x6-3-2-algorithm"><span class="secno">6.3.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-6" aria-label="Permalink for 6.3.2 Algorithm" title="Permalink for 6.3.2 Algorithm"><span>§</span></a></span></h4>

      <p>This algorithm takes three required inputs and three optional inputs.
        The required inputs are an <var>active context</var>, an <var>inverse context</var>,
        and the <var>var</var> to be compacted. The optional inputs are a <var>value</var> associated
        with the <var>var</var>, a <var>vocab</var> flag which specifies whether the
        passed <var>var</var> should be compacted using the
        <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a>
        <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>, and a <var>reverse</var> flag which specifies whether
        a <a href="#dfn-reverse-properties" class="internalDFN" data-link-type="dfn">reverse property</a> is being compacted. If not passed, <var>value</var> is set to
        <code>null</code> and <var>vocab</var> and <var>reverse</var> are both set to
        <code>false</code>.</p>

      <ol>
        <li>If <var>var</var> is <code>null</code>, return <code>null</code>.</li>
        <li>If <var>vocab</var> is <code>true</code> and <var>var</var> is a
          key in <var>inverse context</var>:
          <ol>
            <li>Initialize <var>default language</var> to
              <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a>
              <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>, if it has one, otherwise to
              <code>@none</code>.</li>
            <li class="changed">If <var>value</var> is a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> containing
              the property <code>@preserve</code>, use the first
              element from the value of <code>@preserve</code> as <var>value</var>.</li>
            <li>Initialize <var>containers</var> to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. This
              <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> will be used to keep track of an ordered list of
              preferred <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
              for a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, based on what is compatible with
              <var>value</var>.</li>
            <li>Initialize <var>type/language</var> to <code>@language</code>,
              and <var>type/language value</var> to <code>@null</code>. These two
              variables will keep track of the preferred
              <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> for
              a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, based on what is compatible with <var>value</var>.</li>
            <li>If <var>value</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>,
              that contains the key <code>@index</code>,
              <span class="changed">and <var>value</var> is not a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a></span>
              then append the values <code>@index</code> <span class="changed">and <code>@index@set</code></span> to <var>containers</var>.</li>
            <li>If <var>reverse</var> is <code>true</code>, set <var>type/language</var>
              to <code>@type</code>, <var>type/language value</var> to
              <code>@reverse</code>, and append <code>@set</code> to <var>containers</var>.</li>
            <li>Otherwise, if <var>value</var> is a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, then set
              <var>type/language</var> and <var>type/language value</var>
              to the most specific values that work for all items in
              the list as follows:
              <ol>
                <li>If <code>@index</code> is a not key in <var>value</var>, then
                  append <code>@list</code> to <var>containers</var>.</li>
                <li>Initialize <var>list</var> to the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> associated
                  with the key <code>@list</code> in <var>value</var>.</li>
                <li>Initialize <var>common type</var> and <var>common language</var> to <code>null</code>. If
                  <var>list</var> is empty, set <var>common language</var> to
                  <var>default language</var>.</li>
                <li>For each <var>item</var> in <var>list</var>:
                  <ol>
                    <li>Initialize <var>item language</var> to <code>@none</code> and
                      <var>item type</var> to <code>@none</code>.</li>
                    <li>If <var>item</var> contains the key <code>@value</code>:
                      <ol>
                        <li>If <var>item</var> contains the key <code>@language</code>,
                          then set <var>item language</var> to its associated
                          value.</li>
                        <li>Otherwise, if <var>item</var> contains the key
                          <code>@type</code>, set <var>item type</var> to its
                          associated value.</li>
                        <li>Otherwise, set <var>item language</var> to
                          <code>@null</code>.</li>
                      </ol>
                    </li>
                    <li>Otherwise, set <var>item type</var> to <code>@id</code>.</li>
                    <li>If <var>common language</var> is <code>null</code>, set it
                      to <var>item language</var>.</li>
                    <li>Otherwise, if <var>item language</var> does not equal
                      <var>common language</var> and <var>item</var> contains the
                      key <code>@value</code>, then set <var>common language</var>
                      to <code>@none</code> because list items have conflicting
                      languages.</li>
                    <li>If <var>common type</var> is <code>null</code>, set it
                      to <var>item type</var>.</li>
                    <li>Otherwise, if <var>item type</var> does not equal
                      <var>common type</var>, then set <var>common type</var>
                      to <code>@none</code> because list items have conflicting
                      types.</li>
                    <li>If <var>common language</var> is <code>@none</code> and
                      <var>common type</var> is <code>@none</code>, then
                      stop processing items in the list because it has been
                      detected that there is no common language or type amongst
                      the items.</li>
                  </ol>
                </li>
                <li>If <var>common language</var> is <code>null</code>, set it to
                  <code>@none</code>.</li>
                <li>If <var>common type</var> is <code>null</code>, set it to
                  <code>@none</code>.</li>
                <li>If <var>common type</var> is not <code>@none</code> then set
                  <var>type/language</var> to <code>@type</code> and
                  <var>type/language value</var> to <var>common type</var>.</li>
                <li>Otherwise, set <var>type/language value</var> to
                  <var>common language</var>.</li>
              </ol>
            </li>
            <li class="changed">Otherwise, if <var>value</var> is a <a href="#dfn-graph-objects" class="internalDFN" data-link-type="dfn">graph object</a>,
              prefer a mapping most appropriate for the particular value.
              <ol>
                <li>If value contains the key <code>@index</code>,
                  append the values <code>@graph@index</code> and <code>@graph@index@set</code>
                  to <var>containers</var>.</li>
                <li>If the value contains the key <code>@id</code>,
                  append the values <code>@graph@id</code> and <code>@graph@id@set</code>
                  to <var>containers</var>.</li>
                <li>Append the values <code>@graph</code> <code>@graph@set</code>,
                  and <code>@set</code>
                  to <var>containers</var>.</li>
                <li>If value does not contain the key <code>@index</code>,
                  append the values <code>@graph@index</code> and <code>@graph@index@set</code>
                  to <var>containers</var>.</li>
                <li>If the value does not contain the key <code>@id</code>,
                  append the values <code>@graph@id</code> and <code>@graph@id@set</code>
                  to <var>containers</var>.</li>
                <li>Append the values <code>@index</code> and <code>@index@set</code>
                  to <var>containers</var>.</li>
              </ol>
            </li>
            <li>Otherwise:
              <ol>
                <li>If <var>value</var> is a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>:
                  <ol>
                    <li>If <var>value</var> contains the key <code>@language</code>
                      and does not contain the key <code>@index</code>,
                      then set <var>type/language value</var> to its associated
                      value and, append <code>@language</code>
                      <span class="changed">and <code>@language@set</code></span> to
                      <var>containers</var>.</li>
                    <li>Otherwise, if <var>value</var> contains the key
                      <code>@type</code>, then set <var>type/language value</var> to
                      its associated value and set <var>type/language</var> to
                      <code>@type</code>.</li>
                  </ol>
                </li>
                <li>Otherwise, set <var>type/language</var> to <code>@type</code>
                  and set <var>type/language value</var> to <code>@id</code>,
                  <span class="changed">and append <code>@id</code>, <code>@id@set</code>,
                    <code>@type</code>, and <code>@set@type</code></span>,
                  to <var>containers</var>.</li>
                <li>Append <code>@set</code> to <var>containers</var>.</li>
              </ol>
            </li>
            <li>Append <code>@none</code> to <var>containers</var>. This represents
              the non-existence of a <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>, and it will
              be the last <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> value to be checked as it
              is the most generic.</li>
            <li class="changed">
              If <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a> is <code>json-ld-1.1</code> and value does not contain the key <code>@index</code>, append
              <code>@index</code> and <code>@index@set</code> to <var>containers</var>.
            </li>
            <li class="changed">
              If <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a> is <code>json-ld-1.1</code> and value contains only the key <code>@value</code>, append
              <code>@language</code> and <code>@language@set</code> to <var>containers</var>.
            </li>
            <li>If <var>type/language value</var> is <code>null</code>, set it to
              <code>@null</code>. This is the key under which <code>null</code> values
              are stored in the <var>inverse context</var> <var>entry</var>.</li>
            <li>Initialize <var>preferred values</var> to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.
              This <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> will indicate, in order, the preferred values for
              a <a data-lt="term" href="#dfn-terms" class="internalDFN" data-link-type="dfn">term's</a> <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or
              <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>.</li>
            <li>If <var>type/language value</var> is <code>@reverse</code>, append
              <code>@reverse</code> to <var>preferred values</var>.</li>
            <li>If <var>type/language value</var> is <code>@id</code> or <code>@reverse</code>
              and <var>value</var> has an <code>@id</code> member:
              <ol>
                <li>If the result of using the
                  <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> compaction algorithm</a>,
                  passing <var>active context</var>, <var>inverse context</var>,
                  the value associated with the <code>@id</code> key in <var>value</var> for
                  <var>var</var>, and <code>true</code> for <var>vocab</var> has a
                  <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in the <var>active context</var>
                  with an <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> that equals the value associated
                  with the <code>@id</code> key in <var>value</var>,
                  then append <code>@vocab</code>, <code>@id</code>, and
                  <code>@none</code>, in that order, to <var>preferred values</var>.</li>
                <li>Otherwise, append <code>@id</code>, <code>@vocab</code>, and
                  <code>@none</code>, in that order, to <var>preferred values</var>.</li>
              </ol>
            </li>
            <li>Otherwise, append <var>type/language value</var> and <code>@none</code>, in
              that order, to <var>preferred values</var>.
              <span class="changed">If <var>value</var> is an empty <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>,
                set <var>type/language</var> to <code>@any</code>.</span></li>
            <li>Initialize <var>term</var> to the result of the
              <a href="#term-selection">Term Selection algorithm</a>, passing
              <var>inverse context</var>, <var>var</var>, <var>containers</var>,
              <var>type/language</var>, and <var>preferred values</var>.</li>
            <li>If <var>term</var> is not <code>null</code>, return <var>term</var>.</li>
          </ol>
        </li>
        <li>At this point, there is no simple <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that <var>var</var>
          can be compacted to. If <var>vocab</var> is <code>true</code> and
          <var>active context</var> has a <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>:
          <ol>
            <li>If <var>var</var> begins with the
              <a data-lt="vocabulary mapping" href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping's</a> value
              but is longer, then initialize <var>suffix</var> to the substring
              of <var>var</var> that does not match. If <var>suffix</var> does not
              have a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var>,
              then return <var>suffix</var>.</li>
          </ol>
        </li>
        <li>The <var>var</var> could not be compacted using the
          <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a> <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a>.
          Try to create a <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, starting by initializing
          <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var> to <code>null</code>. This variable will be used to
          tore the created <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, if any.</li>
        <li>For each key <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> and value <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in
          the <var>active context</var>:
          <ol>
            <li>If the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> is <code>null</code>,
              its <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> equals <var>var</var>, its
              <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a> is not a substring at the beginning of
              <var>var</var>,
              <span class="changed"> or the term definition does not contain
                the <a href="#dfn-prefix-flag" class="internalDFN" data-link-type="dfn">prefix flag</a> having a value of <code>true</code>,</span>
              the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> cannot be used as a <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefix</a>.
              Continue with the next <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>.</li>
            <li>Initialize <var>candidate</var> by concatenating <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>,
              a colon (<code>:</code>), and the substring of <var>var</var>
              that follows after the value of the
              <a data-lt="term definition" href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition's</a>
              <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>.</li>
            <li>If either <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var> is <code>null</code>, <var>candidate</var> is
              shorter or the same length but lexicographically less than
              <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var> and <var>candidate</var> does not have a
              <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in <var>active context</var>, or if the
              <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> has an <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>
              that equals <var>var</var> and <var>value</var> is <code>null</code>,
              set <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var> to <var>candidate</var>.</li>
          </ol>
        </li>
        <li>If <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var> is not <code>null</code>, return <var>compact <abbr title="Internationalized Resource Identifier">IRI</abbr></var>.</li>
        <li>If <var>vocab</var> is <code>false</code>,
          transform <var>var</var> to a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> using
          the <span class="changed"><a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> from <var>active context</var>, if it exists</span>.</li>
        <li>Finally, return <var>var</var> as is.</li>
      </ol>
    </section>
  </section> <!-- end of IRI Compaction -->

  <section id="term-selection">
    <h3 id="x6-4-term-selection"><span class="secno">6.4 </span>Term Selection&nbsp;<span class="permalink"><a href="#term-selection" aria-label="Permalink for 6.4 Term Selection" title="Permalink for 6.4 Term Selection"><span>§</span></a></span></h3>

    <p>This algorithm, invoked via the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>,
      makes use of an <a data-lt="active context" href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context's</a>
      <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a> to find the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that is best
      used to <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compact</a> an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>. Other
      information about a value associated with the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> is given,
      including which <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
      and which <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> would
      be best used to express the value.</p>

    <section class="informative" id="overview-7">
      <h4 id="x6-4-1-overview"><span class="secno">6.4.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-7" aria-label="Permalink for 6.4.1 Overview" title="Permalink for 6.4.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>The <a data-lt="inverse context" href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context's</a> entry for
        the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> will be first searched according to the preferred
        <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>, in the order
        that they are given. Amongst <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> with a matching
        <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>, preference will be given to those
        with a matching <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>,
        over those without a <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or
        <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>. If there is no <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
        with a matching <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> then the <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
        without a <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> that matches the given
        <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> is selected. If
        there is still no selected <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>, then a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>
        with no <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> will
        be selected if available. No <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> will be selected that
        has a conflicting <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>.
        Ties between <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">terms</a> that have the same
        mappings are resolved by first choosing the shortest terms, and then by
        choosing the lexicographically least term. Note that these ties are
        resolved automatically because they were previously resolved when the
        <a href="#inverse-context-creation">Inverse Context Creation algorithm</a>
        was used to create the <a href="#dfn-inverse-context" class="internalDFN" data-link-type="dfn">inverse context</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-7">
      <h4 id="x6-4-2-algorithm"><span class="secno">6.4.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-7" aria-label="Permalink for 6.4.2 Algorithm" title="Permalink for 6.4.2 Algorithm"><span>§</span></a></span></h4>

      <p>This algorithm has five required inputs. They are:
        an <var>inverse context</var>, a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> or <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        <var>var</var>, an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>containers</var> that represents an
        ordered list of preferred <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>,
        a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> <var>type/language</var> that indicates whether
        to look for a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> with a matching <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>
        or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>, and an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> representing
        an ordered list of <var>preferred values</var> for the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a>
        or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> to look for.</p>

      <ol>
        <li>Initialize <var>container map</var> to the value associated with
          <var>var</var> in the <var>inverse context</var>.</li>
        <li>For each item <var>container</var> in <var>containers</var>:
          <ol>
            <li>If <var>container</var> is not a key in <var>container map</var>, then
              there is no <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> with a matching
              <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> for it, so continue to the next
              <var>container</var>.</li>
            <li>Initialize <var>type/language map</var> to the value associated
              with the <var>container</var> member in <var>container map</var>.</li>
            <li>Initialize <var>value map</var> to the value associated
              with <var>type/language</var> member in <var>type/language map</var>.</li>
            <li>For each <var>item</var> in <var>preferred values</var>:
              <ol>
                <li>If <var>item</var> is not a key in <var>value map</var>,
                  then there is no <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> with a matching
                  <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a>,
                  so continue to the next <var>item</var>.</li>
                <li>Otherwise, a matching term has been found, return the value
                  associated with the <var>item</var> member in
                  <var>value map</var>.</li>
              </ol>
            </li>
          </ol>
        </li>
        <li>No matching term has been found. Return <code>null</code>.</li>
      </ol>
    </section>

    <section class="informative" id="examples">
      <h4 id="x6-4-3-examples"><span class="secno">6.4.3 </span>Examples&nbsp;<span class="permalink"><a href="#examples" aria-label="Permalink for 6.4.3 Examples" title="Permalink for 6.4.3 Examples"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>
      <p>The following examples are intended to illustrate how the term selection algorithm
        behaves for different term definitions and values. It is not comprehensive, but
        intended to illustrate different parts of the algorithm.</p>

      <section id="language-map-term">
        <h5 id="x6-4-3-1-language-map-term"><span class="secno">6.4.3.1 </span>Language Map Term&nbsp;<span class="permalink"><a href="#language-map-term" aria-label="Permalink for 6.4.3.1 Language Map Term" title="Permalink for 6.4.3.1 Language Map Term"><span>§</span></a></span></h5>
        <p>If the term definition has <code>"@container": "@language"</code>, it will only match a
          <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> having no <code>@type</code>.</p>
        <div class="example"><div class="example-title marker"><span>Example 14</span><span style="text-transform: none">: Term definition with language map</span></div><pre class="hljs json" aria-busy="false">{
  <span class="hljs-attr">"@context"</span>: {<span class="hljs-attr">"t"</span>: {<span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://example/t"</span>, <span class="hljs-attr">"@container"</span>: <span class="hljs-string">"@language"</span>}}
}</pre></div>
        <p>The inverse context will contain the following:</p>
        <pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@language"</span>: {
    <span class="hljs-attr">"@language"</span>: {<span class="hljs-attr">"@none"</span>: <span class="hljs-string">"t"</span>},
    <span class="hljs-attr">"@type"</span>: {<span class="hljs-attr">"@none"</span>: <span class="hljs-string">"t"</span>},
    <span class="hljs-attr">"@any"</span>: {<span class="hljs-attr">"@none"</span>: <span class="hljs-string">"t"</span>}
  }
}
        </pre>

        <aside class="example" data-ignore=""><div class="example-title marker"><span>Example 15</span><span style="text-transform: none">: Language map term with language value</span></div>
          <p>Given the member <code>{"http://example/t": {"@value": "foo", "@type": "http:/example/type"}}</code>,
            The algorithm will be invoked as follows:</p>
          <dl>
            <dt><var>containers</var></dt>
            <dd><code>["@language", "@language@set", "@set", "@none", "@index", "@index@set"]</code></dd>
            <dt><var>type/language</var></dt>
            <dd><code>@language</code></dd>
            <dt><var>preferred values</var></dt>
            <dd><code>["en", "@none"]</code></dd>
          </dl>
          <p>The <var>value map</var> will be set to <code>{"@none"=&gt;"t"}</code>,
            as <var>preferred values</var> contains <code>"@none"</code>,
            the algorithm returns <code>"t"</code> as the term to use for compaction.</p>
        </aside>
      </section>

      <section id="datatyped-term">
        <h5 id="x6-4-3-2-datatyped-term"><span class="secno">6.4.3.2 </span>Datatyped Term&nbsp;<span class="permalink"><a href="#datatyped-term" aria-label="Permalink for 6.4.3.2 Datatyped Term" title="Permalink for 6.4.3.2 Datatyped Term"><span>§</span></a></span></h5>
        <p>If the term definition has a datatype, it will only match a
          <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> having a matching datatype.</p>
        <div class="example"><div class="example-title marker"><span>Example 16</span><span style="text-transform: none">: Term definition with datatype</span></div><pre class="hljs json" data-ignore="" aria-busy="false">{
  <span class="hljs-attr">"@context"</span>: {<span class="hljs-attr">"t"</span>: {<span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://example/t"</span>, <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"http:/example/type"</span>}}
}</pre></div>
        <p>The inverse context will contain the following:</p>
        <pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@none"</span>: {
    <span class="hljs-attr">"@language"</span>: {},
    <span class="hljs-attr">"@type"</span>: {<span class="hljs-attr">"http:/example/type"</span>: <span class="hljs-string">"t"</span>},
    <span class="hljs-attr">"@any"</span>: {<span class="hljs-attr">"@none"</span>: <span class="hljs-string">"t"</span>}
  }
}
        </pre>

        <aside class="example" data-ignore=""><div class="example-title marker"><span>Example 17</span><span style="text-transform: none">: Datatyped term with datatyped value</span></div>
          <p>Given the member <code>{"http://example/t": {"@value": "foo", "@type": "http:/example/type"}}</code>,
            The algorithm will be invoked as follows:</p>
          <dl>
            <dt><var>containers</var></dt>
            <dd><code>["@set", "@none", "@index", "@index@set"]</code></dd>
            <dt><var>type/language</var></dt>
            <dd><code>@type</code></dd>
            <dt><var>preferred values</var></dt>
            <dd><code>["http:/example/type", "@none"]</code></dd>
          </dl>
          <p>The <var>value map</var> will be set to <code>{"http:/example/type": "t"}</code>,
            as <var>preferred values</var> contains <code>"http:/example/type"</code>,
            the algorithm returns <code>"t"</code> as the term to use for compaction.</p>
        </aside>

        <aside class="example" data-ignore=""><div class="example-title marker"><span>Example 18</span><span style="text-transform: none">: Datatyped term with simple value</span></div>
          <p>Given the member <code>{"http://example/t": {"@value": "foo"}}</code>,
            The algorithm will be invoked as follows:</p>
          <dl>
            <dt><var>containers</var></dt>
            <dd><code>["@set", "@none", "@index", "@index@set", "@language", "@language@set"]</code></dd>
            <dt><var>type/language</var></dt>
            <dd><code>@language</code></dd>
            <dt><var>preferred values</var></dt>
            <dd><code>["@null", "@none"]</code></dd>
          </dl>
          <p>The <var>value map</var> will be set to <code>{"@none": "t"}</code>,
            as no key in <var>preferred values</var> matches a key in <var>value map</var>,
            the algorithm returns <code>null</code> and no term is found.</p>
        </aside>

        <aside class="example" data-ignore=""><div class="example-title marker"><span>Example 19</span><span style="text-transform: none">: Datatyped term with object value</span></div>
          <p>Given the member <code>{"http://example/t": {"@id": "http://example/id"}}</code>,
            The algorithm will be invoked as follows:</p>
          <dl>
            <dt><var>containers</var></dt>
            <dd><code>["@id", "@id@set", "@type", "@set@type", "@set", "@none", "@index", "@index@set"]</code></dd>
            <dt><var>type/language</var></dt>
            <dd><code>@type</code></dd>
            <dt><var>preferred values</var></dt>
            <dd><code>["@id", "@vocab", "@none"]</code></dd>
          </dl>
          <p>The <var>value map</var> will be set to <code>{"http:/example/type": "t"}</code>,
            as no key in <var>preferred values</var> matches a key in <var>value map</var>,
            the algorithm returns <code>null</code> and no term is found.</p>
        </aside>
      </section>
    </section>
  </section> <!-- end of Term Selection -->

  <section id="value-compaction">
    <h3 id="x6-5-value-compaction"><span class="secno">6.5 </span>Value Compaction&nbsp;<span class="permalink"><a href="#value-compaction" aria-label="Permalink for 6.5 Value Compaction" title="Permalink for 6.5 Value Compaction"><span>§</span></a></span></h3>

    <p><a href="#dfn-expanded" class="internalDFN" data-link-type="dfn">Expansion</a> transforms all values into <a href="#dfn-expanded-form" class="internalDFN" data-link-type="dfn">expanded form</a>
      in JSON-LD. This algorithm performs the opposite operation, transforming
      a value into <dfn data-lt="compact form|compacted form" data-dfn-type="dfn" id="dfn-compact-form">compacted form</dfn>. This algorithm compacts a
      value according to the <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> in the given
      <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a> that is associated with the value's associated
      <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a>.</p>

    <section class="informative" id="overview-8">
      <h4 id="x6-5-1-overview"><span class="secno">6.5.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-8" aria-label="Permalink for 6.5.1 Overview" title="Permalink for 6.5.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>The <var>value</var> to compact has either an <code>@id</code> or an
        <code>@value</code> member.</p>

      <p>For the former case, if the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> of
        <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> is set to <code>@id</code> or <code>@vocab</code>
        and <var>value</var> consists of only an <code>@id</code> member and, if
        the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> of <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a>
        <span class="changed">includes</span> <code>@index</code>, an <code>@index</code> member, <var>value</var>
        can be compacted to a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> by returning the result of
        using the <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> Compaction algorithm</a>
        to compact the value associated with the <code>@id</code> member.
        Otherwise, <var>value</var> cannot be compacted and is returned as is.</p>

      <p>For the latter case, it might be possible to compact <var>value</var>
        just into the value associated with the <code>@value</code> member.
        This can be done if the <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> has a matching
        <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> or <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> and there
        is either no <code>@index</code> member or the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
        of <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> <span class="changed">includes</span> <code>@index</code>. It can
        also be done if <code>@value</code> is the only member in <var>value</var>
        (apart an <code>@index</code> member in case the <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a>
        of <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a> <span class="changed">includes</span> <code>@index</code>) and
        either its associated value is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>, there is
        no <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>, or there is an explicit
        <code>null</code> <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> for the
        <a href="#dfn-active-property" class="internalDFN" data-link-type="dfn">active property</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-8">
      <h4 id="x6-5-2-algorithm"><span class="secno">6.5.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-8" aria-label="Permalink for 6.5.2 Algorithm" title="Permalink for 6.5.2 Algorithm"><span>§</span></a></span></h4>

      <p>This algorithm has four required inputs: an <var>active context</var>, an
        <var>inverse context</var>,  an <var>active property</var>, and a <var>value</var>
        to be compacted.</p>

      <ol>
        <li>Initialize <var>number members</var> to the number of members
          <var>value</var> contains.</li>
        <li>If <var>value</var> has an <code>@index</code> member and the
          <a href="#dfn-container-mappings" class="internalDFN" data-link-type="dfn">container mapping</a> associated to <var>active property</var>
          <span class="changed">includes</span> <code>@index</code>, decrease <var>number members</var> by
          <code>1</code>.</li>
        <li>If <var>number members</var> is greater than <code>2</code>, return
          <var>value</var> as it cannot be compacted.</li>
        <li>If <var>value</var> has an <code>@id</code> member:
          <ol>
            <li>If <var>number members</var> is <code>1</code> and
              the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> of <var>active property</var>
              is set to <code>@id</code>, return the result of using the
              <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> compaction algorithm</a>,
              passing <var>active context</var>, <var>inverse context</var>,
              and the value of the <code>@id</code> member for <var>var</var>.</li>
            <li>Otherwise, if <var>number members</var> is <code>1</code> and
              the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> of <var>active property</var>
              is set to <code>@vocab</code>, return the result of using the
              <a href="#iri-compaction"><abbr title="Internationalized Resource Identifier">IRI</abbr> compaction algorithm</a>,
              passing <var>active context</var>, <var>inverse context</var>,
              the value of the <code>@id</code> member for <var>var</var>, and
              <code>true</code> for <var>vocab</var>.</li>
            <li>Otherwise, return <var>value</var> as is.</li>
          </ol>
        </li>
        <li>Otherwise, if <var>value</var> has an <code>@type</code> member whose
          value matches the <a href="#dfn-type-mappings" class="internalDFN" data-link-type="dfn">type mapping</a> of <var>active property</var>,
          return the value associated with the <code>@value</code> member
          of <var>value</var>.</li>
        <li>Otherwise, if <var>value</var> has an <code>@language</code> member whose
          value matches the <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> of
          <var>active property</var>, return the value associated with the
          <code>@value</code> member of <var>value</var>.</li>
        <li>Otherwise, if <var>number members</var> equals <code>1</code> and either
          the value of the <code>@value</code> member is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>,
          or the <var>active context</var> has no <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a>,
          or the <a href="#dfn-language-mappings" class="internalDFN" data-link-type="dfn">language mapping</a> of <var>active property</var>
          is set to <code>null</code>,, return the value associated with the
          <code>@value</code> member.</li>
        <li>Otherwise, return <var>value</var> as is.</li>
      </ol>
    </section>
  </section> <!-- end of Value Compaction algorithm -->
</section> <!-- end of Compaction section -->


<section id="flattening-algorithms">
  <!--OddPage--><h2 id="x7-flattening-algorithms"><span class="secno">7. </span>Flattening Algorithms&nbsp;<span class="permalink"><a href="#flattening-algorithms" aria-label="Permalink for 7. Flattening Algorithms" title="Permalink for 7. Flattening Algorithms"><span>§</span></a></span></h2>

  <section id="flattening-algorithm">
    <h3 id="x7-1-flattening-algorithm"><span class="secno">7.1 </span>Flattening Algorithm&nbsp;<span class="permalink"><a href="#flattening-algorithm" aria-label="Permalink for 7.1 Flattening Algorithm" title="Permalink for 7.1 Flattening Algorithm"><span>§</span></a></span></h3>

    <p>This algorithm flattens an expanded JSON-LD document by collecting all
      properties of a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in a single <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
      and labeling all <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank nodes</a> with
      <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>.
      This resulting uniform shape of the document, may drastically simplify
      the code required to process JSON-LD data in certain applications.</p>

    <section class="informative" id="overview-9">
      <h4 id="x7-1-1-overview"><span class="secno">7.1.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-9" aria-label="Permalink for 7.1.1 Overview" title="Permalink for 7.1.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>First, a <var>node map</var> is generated using the
        <a href="#node-map-generation">Node Map Generation algorithm</a>
        which collects all properties of a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> in a single
        <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. In the next step, the <var>node map</var> is
        converted to a JSON-LD document in
        <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/#flattened-document-form">flattened document form</a>.
        Finally, if a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> has been passed, the flattened document
        is compacted using the <a href="#compaction-algorithm">Compaction algorithm</a>
        before being returned.</p>
    </section>

    <section class="algorithm" id="algorithm-9">
      <h4 id="x7-1-2-algorithm"><span class="secno">7.1.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-9" aria-label="Permalink for 7.1.2 Algorithm" title="Permalink for 7.1.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes two input variables, an <var>element</var> to flatten and
        an optional <var>context</var> used to compact the flattened document. If not
        passed, <var>context</var> is set to <code>null</code>.</p>

      <p>This algorithm generates new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>
        and relabels existing <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>.
        The <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>
        keeps an <var>identifier map</var> and a <var>counter</var> to ensure consistent
        relabeling and avoid collisions. Thus, before this algorithm is run,
        the <var>identifier map</var> is reset and the <var>counter</var> is initialized
        to <code>0</code>.</p>

      <ol>
        <li>Initialize <var>node map</var> to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of
          a single member whose key is <code>@default</code> and whose value is
          an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li>Perform the <a href="#node-map-generation">Node Map Generation algorithm</a>, passing
          <var>element</var> and <var>node map</var>.</li>
        <li>Initialize <var>default graph</var> to the value of the <code>@default</code>
          member of <var>node map</var>, which is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> representing
          the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a>.</li>
        <li>For each key-value pair <var>graph name</var>-<var>graph</var> in <var>node map</var>
          where <var>graph name</var> is not <code>@default</code>,  perform the following steps:
          <ol>
            <li>If <var>default graph</var> does not have a <var>graph name</var> member, create
              one and initialize its value to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of an
              <code>@id</code> member whose value is set to <var>graph name</var>.</li>
            <li>Reference the value associated with the <var>graph name</var> member in
              <var>default graph</var> using the variable <var>entry</var>.</li>
            <li>Add an <code>@graph</code> member to <var>entry</var> and set it to an
              empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
            <li>For each <var>id</var>-<var>node</var> pair in <var>graph</var> ordered by <var>id</var>,
              add <var>node</var> to the <code>@graph</code> member of <var>entry</var>,
              unless the only member of <var>node</var> is <code>@id</code>.</li>
          </ol>
        </li>
        <li>Initialize an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>flattened</var>.</li>
        <li>For each <var>id</var>-<var>node</var> pair in <var>default graph</var> ordered by <var>id</var>,
          add <var>node</var> to <var>flattened</var>,
          unless the only member of <var>node</var> is <code>@id</code>.</li>
        <li>If <var>context</var> is <code>null</code>, return <var>flattened</var>.</li>
        <li>Otherwise, return the result of <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> <var>flattened</var> according the
          <a href="#compaction-algorithm">Compaction algorithm</a> passing <var>context</var>
          ensuring that the compaction result has only the <code>@graph</code> keyword (or its alias)
          at the top-level other than <code>@context</code>, even if the context is empty or if there is only one element to
          put in the <code>@graph</code> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. This ensures that the returned
          document has a deterministic structure.</li>
      </ol>
    </section>
  </section> <!-- end of Flattening Algorithm -->

  <section id="node-map-generation">
    <h3 id="x7-2-node-map-generation"><span class="secno">7.2 </span>Node Map Generation&nbsp;<span class="permalink"><a href="#node-map-generation" aria-label="Permalink for 7.2 Node Map Generation" title="Permalink for 7.2 Node Map Generation"><span>§</span></a></span></h3>

    <p>This algorithm creates a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>node map</var> holding an indexed
      representation of the <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">graphs</a> and <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">nodes</a>
      represented in the passed expanded document. All <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">nodes</a> that are not
      uniquely identified by an <abbr title="Internationalized Resource Identifier">IRI</abbr> get assigned a (new) <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.
      The resulting <var>node map</var> will have a member for every graph in the document whose
      value is another object with a member for every <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> represented in the document.
      The default graph is stored under the <code>@default</code> member, all other graphs are
      stored under their <a href="#dfn-graph-names" class="internalDFN" data-link-type="dfn">graph name</a>.</p>

    <section class="informative" id="overview-10">
      <h4 id="x7-2-1-overview"><span class="secno">7.2.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-10" aria-label="Permalink for 7.2.1 Overview" title="Permalink for 7.2.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>The algorithm recursively runs over an expanded JSON-LD document to
        collect all <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a> of a <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a>
        in a single <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. The algorithm constructs a
        <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>node map</var> whose keys represent the
        <a href="#dfn-graph-names" class="internalDFN" data-link-type="dfn">graph names</a> used in the document
        (the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a> is stored under the key <code>@default</code>)
        and whose associated values are <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>
        which index the <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">nodes</a> in the
        <a href="#dfn-graph" class="internalDFN" data-link-type="dfn">graph</a>. If a
        <a data-lt="property" href="#dfn-properties" class="internalDFN" data-link-type="dfn">property's</a> value is a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>,
        it is replaced by a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> consisting of only an
        <code>@id</code> member. If a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> has no <code>@id</code>
        member or it is identified by a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,
        a new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> is generated. This relabeling
        of <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a> is
        also done for <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">properties</a> and values of
        <code>@type</code>.</p>
    </section>

    <section class="algorithm" id="algorithm-10">
      <h4 id="x7-2-2-algorithm"><span class="secno">7.2.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-10" aria-label="Permalink for 7.2.2 Algorithm" title="Permalink for 7.2.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes as input an expanded JSON-LD document <var>element</var> and a reference to
        a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>node map</var>. Furthermore it has the optional parameters
        <var>active graph</var> (which defaults to <code>@default</code>), an <var>active subject</var>,
        <var>active property</var>, and a reference to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>list</var>. If
        not passed, <var>active subject</var>, <var>active property</var>, and <var>list</var> are
        set to <code>null</code>.</p>

      <ol>
        <li>If <var>element</var> is an array, process each <var>item</var> in <var>element</var>
          as follows and then return:
          <ol>
            <li>Run this algorithm recursively by passing <var>item</var> for <var>element</var>,
              <var>node map</var>, <var>active graph</var>, <var>active subject</var>,
              <var>active property</var>, and <var>list</var>.</li>
          </ol>
        </li>
        <li>Otherwise <var>element</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>. Reference the
          <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> which is the value of the <a href="#dfn-active-graph" class="internalDFN" data-link-type="dfn">active graph</a>
          member of <var>node map</var> using the variable <var>graph</var>. If the
          <var>active subject</var> is <code>null</code>, set <var>node</var> to <code>null</code>
          otherwise reference the <var>active subject</var> member of <var>graph</var> using the
          variable <var>node</var>.</li>
        <li>If <var>element</var> has an <code>@type</code> member, perform for each
          <var>item</var> the following steps:
          <ol>
            <li>If <var>item</var> is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, replace it with a newly
              <a href="#generate-blank-node-identifier">generated blank node identifier</a>
              passing <var>item</var> for <var>identifier</var>.</li>
          </ol>
        </li>
        <li>If <var>element</var> has an <code>@value</code> member, perform the following steps:
          <ol>
            <li>If <var>list</var> is <code>null</code>:
              <ol>
                <li>If <var>node</var> does not have an <var>active property</var> member,
                  create one and initialize its value to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                  containing <var>element</var>.</li>
                <li>Otherwise, compare <var>element</var> against every item in the
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> associated with the <var>active property</var>
                  member of <var>node</var>. If there is no item equivalent to <var>element</var>,
                  append <var>element</var> to the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Two
                  <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are considered
                  equal if they have equivalent key-value pairs.</li>
              </ol>
            </li>
            <li>Otherwise, append <var>element</var> to the <code>@list</code> member of <var>list</var>.</li>
          </ol>
        </li>
        <li>Otherwise, if <var>element</var> has an <code>@list</code> member, perform
          the following steps:
          <ol>
            <li>Initialize a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>result</var> consisting of a single member
              <code>@list</code> whose value is initialized to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
            <li>Recursively call this algorithm passing the value of <var>element</var>'s
              <code>@list</code> member for <var>element</var>, <var>active graph</var>,
              <var>active subject</var>, <var>active property</var>, and
              <var>result</var> for <var>list</var>.</li>
            <li>Append <var>result</var> to the value of the <var>active property</var> member
              of <var>node</var>.</li>
          </ol>
        </li>
        <li>Otherwise <var>element</var> is a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>, perform
          the following steps:
          <ol>
            <li>If <var>element</var> has an <code>@id</code> member, set <var>id</var>
              to its value and remove the member from <var>element</var>. If <var>id</var>
              is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, replace it with a newly
              <a href="#generate-blank-node-identifier">generated blank node identifier</a>
              passing <var>id</var> for <var>identifier</var>.</li>
            <li>Otherwise, set <var>id</var> to the result of the
              <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>
              passing <code>null</code> for <var>identifier</var>.</li>
            <li>If <var>graph</var> does not contain a member <var>id</var>, create one and initialize
              its value to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of a single member <code>@id</code> whose
              value is <var>id</var>.</li>
            <li>Reference the value of the <var>id</var> member of <var>graph</var> using the
              variable <var>node</var>.</li>
            <li>If <var>active subject</var> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, a reverse property relationship
              is being processed. Perform the following steps:
              <ol>
                <li>If <var>node</var> does not have an <var>active property</var> member,
                  create one and initialize its value to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                  containing <var>active subject</var>.</li>
                <li>Otherwise, compare <var>active subject</var> against every item in the
                  <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> associated with the <var>active property</var>
                  member of <var>node</var>. If there is no item equivalent to <var>active subject</var>,
                  append <var>active subject</var> to the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Two
                  <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are considered
                  equal if they have equivalent key-value pairs.</li>
              </ol>
            </li>
            <li>Otherwise, if <var>active property</var> is not <code>null</code>, perform the following steps:
              <ol>
                <li>Create a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>reference</var> consisting of a single member
                  <code>@id</code> whose value is <var>id</var>.</li>
                <li>If <var>list</var> is <code>null</code>:
                  <ol>
                    <li>If <var>node</var> does not have an <var>active property</var> member,
                      create one and initialize its value to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      containing <var>reference</var>.</li>
                    <li>Otherwise, compare <var>reference</var> against every item in the
                      <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> associated with the <var>active property</var>
                      member of <var>node</var>. If there is no item equivalent to <var>reference</var>,
                      append <var>reference</var> to the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Two
                      <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> are considered
                      equal if they have equivalent key-value pairs.</li>
                  </ol>
                </li>
                <li>Otherwise, append <var class="changed">reference</var> to the <code>@list</code> member of <var>list</var>.</li>
              </ol>
            </li>
            <li>If <var>element</var> has an <code>@type</code> key, append
              each item of its associated <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> to the
              <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> associated with the <code>@type</code> key of
              <var>node</var> unless it is already in that <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Finally
              remove the <code>@type</code> member from <var>element</var>.</li>
            <li>If <var>element</var> has an <code>@index</code> member, set the <code>@index</code>
              member of <var>node</var> to its value. If <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">node</a> has already an
              <code>@index</code> member with a different value, a
              <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-conflicting-indexes" class="internalDFN" data-link-type="dfn"><code>conflicting indexes</code></a>
              error has been detected and processing is aborted. Otherwise, continue by
              removing the <code>@index</code> member from <var>element</var>.</li>
            <li>If <var>element</var> has an <code>@reverse</code> member:
              <ol>
                <li>Create a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> <var>referenced node</var> with a single member <code>@id</code> whose
                  value is <var>id</var>.</li>
                <li>Set <var>reverse map</var> to the value of the <code>@reverse</code> member of
                  <var>element</var>.</li>
                <li>For each key-value pair <var>property</var>-<var>values</var> in <var>reverse map</var>:
                  <ol>
                    <li>For each <var>value</var> of <var>values</var>:
                      <ol>
                        <li>Recursively invoke this algorithm passing <var>value</var> for
                          <var>element</var>, <var>node map</var>, <var>active graph</var>,
                          <var>referenced node</var> for <var>active subject</var>, and
                          <var>property</var> for <var>active property</var>. Passing a
                          <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> for <var>active subject</var> indicates to the
                          algorithm that a reverse property relationship is being processed.</li>
                      </ol>
                    </li>
                  </ol>
                </li>
                <li>Remove the <code>@reverse</code> member from <var>element</var>.</li>
              </ol>
            </li>
            <li>If <var>element</var> has an <code>@graph</code> member, recursively invoke this
              algorithm passing the value of the <code>@graph</code> member for <var>element</var>,
              <var>node map</var>, and <var>id</var> for <var>active graph</var> before removing
              the <code>@graph</code> member from <var>element</var>.</li>
            <li>Finally, for each key-value pair <var>property</var>-<var>value</var> in <var>element</var> ordered by
              <var>property</var> perform the following steps:
              <ol>
                <li>If <var>property</var> is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, replace it with a newly
                  <a href="#generate-blank-node-identifier">generated blank node identifier</a>
                  passing <var>property</var> for <var>identifier</var>.</li>
                <li>If <var>node</var> does not have a <var>property</var> member, create one and initialize
                  its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>Recursively invoke this algorithm passing <var>value</var> for <var>element</var>,
                  <var>node map</var>, <var>active graph</var>, <var>id</var> for <var>active subject</var>,
                  and <var>property</var> for <var>active property</var>.</li>
              </ol>
            </li>
          </ol>
        </li>
      </ol>
    </section>
  </section> <!-- end of Node Map Generation -->

  <section id="generate-blank-node-identifier">
    <h3 id="x7-3-generate-blank-node-identifier"><span class="secno">7.3 </span>Generate Blank Node Identifier&nbsp;<span class="permalink"><a href="#generate-blank-node-identifier" aria-label="Permalink for 7.3 Generate Blank Node Identifier" title="Permalink for 7.3 Generate Blank Node Identifier"><span>§</span></a></span></h3>

    <p>This algorithm is used to generate new
      <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a> or to
      relabel an existing <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> to avoid collision
      by the introduction of new ones.</p>

    <section class="informative" id="overview-11">
      <h4 id="x7-3-1-overview"><span class="secno">7.3.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-11" aria-label="Permalink for 7.3.1 Overview" title="Permalink for 7.3.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>The simplest case is if there exists already a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>
        in the <var>identifier map</var> for the passed <var>identifier</var>, in which
        case it is simply returned. Otherwise, a new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>
        is generated by concatenating the string <code>_:b</code> and the
        <var>counter</var>. If the passed <var>identifier</var> is not <code>null</code>,
        an entry is created in the <var>identifier map</var> associating the
        <var>identifier</var> with the <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>. Finally,
        the <var>counter</var> is increased by one and the new
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> is returned.</p>
    </section>

    <section class="algorithm" id="algorithm-11">
      <h4 id="x7-3-2-algorithm"><span class="secno">7.3.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-11" aria-label="Permalink for 7.3.2 Algorithm" title="Permalink for 7.3.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes a single input variable <var>identifier</var> which may
        be <code>null</code>. Between its executions, the algorithm needs to
        keep an <var>identifier map</var> to relabel existing
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>
        consistently and a <var>counter</var> to generate new
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>. The
        <var>counter</var> is initialized to <code>0</code> by default.</p>

      <ol>
        <li>If <var>identifier</var> is not <code>null</code> and has an entry in the
          <var>identifier map</var>, return the mapped identifier.</li>
        <li>Otherwise, generate a new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> by concatenating
          the string <code>_:b</code> and <var>counter</var>.</li>
        <li>Increment <var>counter</var> by <code>1</code>.</li>
        <li>If <var>identifier</var> is not <code>null</code>, create a new entry
          for <var>identifier</var> in <var>identifier map</var> and set its value
          to the new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.</li>
        <li>Return the new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.</li>
      </ol>
    </section>
  </section> <!-- end of Generate Blank Node Identifier -->

  <section class="changed algorithm" id="merge-node-maps">
    <h3 id="x7-4-merge-node-maps"><span class="secno">7.4 </span>Merge Node Maps&nbsp;<span class="permalink"><a href="#merge-node-maps" aria-label="Permalink for 7.4 Merge Node Maps" title="Permalink for 7.4 Merge Node Maps"><span>§</span></a></span></h3>
    <p>This algorithm creates a new map of <a href="#dfn-subjects" class="internalDFN" data-link-type="dfn">subjects</a> to <a href="#dfn-nodes" class="internalDFN" data-link-type="dfn">nodes</a> using all graphs
      contained in the <var>graph map</var> created using the <a href="#node-map-generation">Node Map Generation algorithm</a>
      to create merged <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a> containing information defined for a given <a href="#dfn-subjects" class="internalDFN" data-link-type="dfn">subject</a>
      in each graph contained in the <var>node map</var>.</p>

    <ol>
      <li>Create <var>result</var> as an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a></li>
      <li>For each <var>graph name</var> and <var>node map</var> in <var>graph map</var>
        and for each <var>id</var> and <var>node</var> in <var>node map</var>:
        <ol>
          <li>Set <var>merged node</var> to the value for <var>id</var> in <var>result</var>, initializing it
            with a new <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of a single member <code>@id</code> whose value is <var>id</var>, if it does not exist.</li>
          <li>For each <var>property</var> and <var>values</var> in <var>node</var>:
            <ol>
              <li>If <var>property</var> is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>, add <var>property</var> and values to <var>merged node</var>.</li>
              <li>Otherwise, merge each element from <var>values</var> into the values for <var>property</var>
                in <var>merged node</var>, initializing it to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> if necessary.</li>
            </ol>
          </li>
        </ol>
      </li>
      <li>Return <var>result</var>.</li>
    </ol>
  </section> <!-- end of Merge Node Maps-->

</section> <!-- end of Flattening section -->


<section id="rdf-serialization-deserialization-algorithms">
  <!--OddPage--><h2 id="x8-rdf-serialization-deserialization-algorithms"><span class="secno">8. </span>RDF Serialization/Deserialization Algorithms&nbsp;<span class="permalink"><a href="#rdf-serialization-deserialization-algorithms" aria-label="Permalink for 8. RDF Serialization/Deserialization Algorithms" title="Permalink for 8. RDF Serialization/Deserialization Algorithms"><span>§</span></a></span></h2>

  <p>This section describes algorithms to deserialize a JSON-LD document to an
    <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a> and vice versa. The algorithms are designed for in-memory
    implementations with random access to <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> elements.</p>

  <p>Throughout this section, the following vocabulary
    <a href="#dfn-prefixes" class="internalDFN" data-link-type="dfn">prefixes</a> are used in
    <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact IRIs</a>:</p>

  <table class="simple">
    <thead><tr>
      <th>Prefix</th>
      <th><abbr title="Internationalized Resource Identifier">IRI</abbr></th>
    </tr></thead>
    <tbody>
      <tr>
        <td>rdf</td>
        <td>http://www.w3.org/1999/02/22-rdf-syntax-ns#</td>
      </tr>
      <tr>
        <td>rdfs</td>
        <td> http://www.w3.org/2000/01/rdf-schema#</td>
      </tr>
      <tr>
        <td>xsd</td>
        <td>http://www.w3.org/2001/XMLSchema#</td>
      </tr>
    </tbody>
  </table>

  <section id="deserialize-json-ld-to-rdf-algorithm">
    <h3 id="x8-1-deserialize-json-ld-to-rdf-algorithm"><span class="secno">8.1 </span>Deserialize JSON-LD to RDF algorithm&nbsp;<span class="permalink"><a href="#deserialize-json-ld-to-rdf-algorithm" aria-label="Permalink for 8.1 Deserialize JSON-LD to RDF algorithm" title="Permalink for 8.1 Deserialize JSON-LD to RDF algorithm"><span>§</span></a></span></h3>

    <p>This algorithm deserializes a JSON-LD document to an <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a>.
      Please note that RDF does not allow a <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a> to be used
      as a <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a>, while JSON-LD does.  Therefore, by default
      RDF triples that would have contained blank nodes as properties are
      discarded when interpreting JSON-LD as RDF.</p>

    <section class="informative" id="overview-12">
      <h4 id="x8-1-1-overview"><span class="secno">8.1.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-12" aria-label="Permalink for 8.1.1 Overview" title="Permalink for 8.1.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>The JSON-LD document is expanded and converted to a <var>node map</var> using the
        <a href="#node-map-generation">Node Map Generation algorithm</a>.
        This allows each graph represented within the document to be
        extracted and flattened, making it easier to process each
        <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>. Each graph from the <var>node map</var>
        is processed to extract <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a>,
        to which any (non-default) graph name is applied to create an
        <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a>. Each <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> in the
        <var>node map</var> has an <code>@id</code> member which corresponds to the
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-subject">RDF subject</a>, the other members
        represent <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-predicate">RDF predicates</a>. Each
        member value is either an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> or can be transformed to an
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literal</a>
        to generate an <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a>. <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">Lists</a>
        are transformed into an
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a>
        using the <a href="#list-to-rdf-conversion">List to RDF Conversion algorithm.</a></p>
    </section>

    <section class="algorithm" id="algorithm-12">
      <h4 id="x8-1-2-algorithm"><span class="secno">8.1.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-12" aria-label="Permalink for 8.1.2 Algorithm" title="Permalink for 8.1.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes a JSON-LD document <var>element</var> and returns an
        <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a>. Unless the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-producegeneralizedrdf" class="internalDFN" data-link-type="dfn"><code>produceGeneralizedRdf</code></a> option
        is set to <code>true</code>, <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a>
        containing a <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a> <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-predicate">predicate</a>
        are excluded from output.</p>

      <p>This algorithm generates new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>
        and relabels existing <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>.
        The <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>
        keeps an <var>identifier map</var> and a <var>counter</var> to ensure consistent
        relabeling and avoid collisions. Thus, before this algorithm is run,
        the <var>identifier map</var> is reset and the <var>counter</var> is initialized
        to <code>0</code>.</p>

      <ol>
        <li>Expand <var>element</var> according to the
          <a href="#expansion-algorithm">Expansion algorithm</a>.</li>
        <li>Generate a <var>node map</var> according to the
          <a href="#node-map-generation">Node Map Generation algorithm</a>.</li>
        <li>Initialize an empty <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a> <var>dataset</var>.</li>
        <li>For each <var>graph name</var> and <var>graph</var> in <var>node map</var>
          ordered by <var>graph name</var>:
          <ol>
            <li>If <var>graph name</var> is a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, continue
              with the next <var>graph name</var>-<var>graph</var> pair.</li>
            <li>Initialize <var>triples</var> as an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
            <li>For each <var>subject</var> and <var>node</var> in <var>graph</var> ordered
              by <var>subject</var>:
              <ol>
                <li>If <var>subject</var> is a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, continue
                  with the next <var>subject</var>-<var>node</var> pair.</li>
                <li>For each <var>property</var> and <var>values</var> in <var>node</var>
                  ordered by <var>property</var>:
                  <ol>
                    <li>If <var>property</var> is <code>@type</code>, then for each
                      <var>type</var> in <var>values</var>, append a <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a>
                      composed of <var>subject</var>, <code>rdf:type</code>,
                      and <var>type</var> to <var>triples</var>.</li>
                    <li>Otherwise, if <var>property</var> is a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a>
                      continue with the next <var>property</var>-<var>values</var> pair.</li>
                    <li>Otherwise, if <var>property</var> is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> and
                      the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-producegeneralizedrdf" class="internalDFN" data-link-type="dfn"><code>produceGeneralizedRdf</code></a> option is not <code>true</code>,
                      continue with the next <var>property</var>-<var>values</var> pair.</li>
                    <li>Otherwise, if <var>property</var> is a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
                      continue with the next <var>property</var>-<var>values</var> pair.</li>
                    <li>Otherwise, <var>property</var> is an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> or
                      <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>. For each <var>item</var>
                      in <var>values</var>:
                      <ol>
                        <li>If <var>item</var> is a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>, initialize
                          <var>list triples</var> as an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> and
                          <var>list head</var> to the result of the <a href="#list-to-rdf-conversion">List Conversion algorithm</a>, passing
                          the value associated with the <code>@list</code> key from
                          <var>item</var> and <var>list triples</var>. Append first a
                          <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a> composed of <var>subject</var>,
                          <var>property</var>, and <var>list head</var> to <var>triples</var> and
                          finally append all <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triples</a> from
                          <var>list triples</var> to <var>triples</var>.</li>
                        <li>Otherwise, <var>item</var> is a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>
                          or a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>. Append a <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a>
                          composed of <var>subject</var>, <var>property</var>, and
                          the result of using the
                          <a href="#object-to-rdf-conversion">Object to RDF Conversion algorithm</a>
                          passing <var>item</var> to <var>triples</var>, unless the result is
                          <code>null</code>, indicating a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> that has
                          to be ignored.</li>
                      </ol>
                    </li>
                  </ol>
                </li>
              </ol>
            </li>
            <li>If <var>graph name</var> is <code>@default</code>, add
              <var>triples</var> to the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a> in <var>dataset</var>.</li>
            <li>Otherwise, create a <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graph</a> in <var>dataset</var>
              composed of <var>graph name</var> and add <var>triples</var>.</li>
          </ol>
        </li>
        <li>Return <var>dataset</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Deserialize JSON-LD to RDF algorithm -->

  <section id="object-to-rdf-conversion">
    <h3 id="x8-2-object-to-rdf-conversion"><span class="secno">8.2 </span>Object to RDF Conversion&nbsp;<span class="permalink"><a href="#object-to-rdf-conversion" aria-label="Permalink for 8.2 Object to RDF Conversion" title="Permalink for 8.2 Object to RDF Conversion"><span>§</span></a></span></h3>

    <p>This algorithm takes a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> or <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>
      and transforms it into an
      <a href="#dfn-resource" class="internalDFN" data-link-type="dfn">RDF resource</a>
      to be used as the <a href="#dfn-objects" class="internalDFN" data-link-type="dfn">object</a> of an <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a>. If a
      <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> containing a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is passed to
      the algorithm, <code>null</code> is returned which then causes the resulting
      <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a> to be ignored.</p>

    <section class="informative" id="overview-13">
      <h4 id="x8-2-1-overview"><span class="secno">8.2.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-13" aria-label="Permalink for 8.2.1 Overview" title="Permalink for 8.2.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p><a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">Value objects</a> are transformed to
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a> as described in
        <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>
        whereas <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a> are transformed
        to <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a>,
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>,
        or <code>null</code>.</p>
    </section>

    <section class="algorithm" id="algorithm-13">
      <h4 id="x8-2-2-algorithm"><span class="secno">8.2.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-13" aria-label="Permalink for 8.2.2 Algorithm" title="Permalink for 8.2.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes as its sole argument <var>item</var> which <em class="rfc2119" title="MUST">MUST</em> be
        either a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> or <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>.</p>

      <ol>
        <li>If <var>item</var> is a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> and the value of
          its <code>@id</code> member is a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>, return
          <code>null</code>.</li>
        <li>If <var>item</var> is a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>, return the
          <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> associated
          with its <code>@id</code> member.</li>
        <li>Otherwise, <var>item</var> is a <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>. Initialize
          <var>value</var> to the value associated with the <code>@value</code>
          member in <var>item</var>.
        </li><li>Initialize <var>datatype</var> to the value associated with the
          <code>@type</code> member of <var>item</var> or  <code>null</code> if
          <var>item</var> does not have such a member.</li>
        <li>If <var>value</var> is <code>true</code> or
          <code>false</code>, set <var>value</var> to the <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>
          <code>true</code> or <code>false</code> which is the
          <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> as described in
          <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>
          If <var>datatype</var> is <code>null</code>, set it to
          <code>xsd:boolean</code>.</li>
        <li>Otherwise, if <var>value</var> is a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> with a non-zero fractional
          part (the result of a modulo‑1 operation) or <var>value</var> is a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>
          and <var>datatype</var> equals <code>xsd:double</code>, convert <var>value</var> to a
          <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> in <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> of
          an <a href="https://www.w3.org/TR/xmlschema11-2/#double"><code>xsd:double</code></a> as defined in [<cite><a class="bibref" href="#bib-XMLSCHEMA11-2">XMLSCHEMA11-2</a></cite>]
          and described in
          <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>.
          If <var>datatype</var> is <code>null</code>, set it to
          <code>xsd:double</code>.</li>
        <li>Otherwise, if <var>value</var> is a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> with no non-zero
          fractional part (the result of a modulo‑1 operation) or <var>value</var>
          is a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> and <var>datatype</var>
          equals <code>xsd:integer</code>, convert <var>value</var> to a
          <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> in <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> of
          an <a href="https://www.w3.org/TR/xmlschema11-2/#integer"><code>xsd:integer</code></a> as defined in [<cite><a class="bibref" href="#bib-XMLSCHEMA11-2">XMLSCHEMA11-2</a></cite>]
          and described in
          <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>.
          If <var>datatype</var> is <code>null</code>, set it to
          <code>xsd:integer</code>.</li>
        <li>Otherwise, if <var>datatype</var> is <code>null</code>, set it to
          <code>xsd:string</code> or <code>rdf:langString</code>, depending on if
          item has an <code>@language</code> member.</li>
        <li>Initialize <var>literal</var> as an <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literal</a> using
          <var>value</var> and <var>datatype</var>. If <var>item</var> has an
          <code>@language</code> member, add the value associated with the
          <code>@language</code> key as the <a href="#dfn-language-tag" class="internalDFN" data-link-type="dfn">language tag</a> of <var>literal</var>.</li>
        <li>Return <var>literal</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Object to RDF Conversion -->

  <section id="list-to-rdf-conversion">
    <h3 id="x8-3-list-to-rdf-conversion"><span class="secno">8.3 </span>List to RDF Conversion&nbsp;<span class="permalink"><a href="#list-to-rdf-conversion" aria-label="Permalink for 8.3 List to RDF Conversion" title="Permalink for 8.3 List to RDF Conversion"><span>§</span></a></span></h3>

    <p>List Conversion is the process of taking a <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>
      and transforming it into an
      <a data-link-type="dfn" href="https://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a>
      as defined in RDF Semantics [<cite><a class="bibref" href="#bib-RDF11-MT">RDF11-MT</a></cite>].</p>

    <section class="informative" id="overview-14">
      <h4 id="x8-3-1-overview"><span class="secno">8.3.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-14" aria-label="Permalink for 8.3.1 Overview" title="Permalink for 8.3.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>For each element of the <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a> a new <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>
        is allocated which is used to generate <code>rdf:first</code> and
        <code>rdf:rest</code> ABBR. The
        algorithm returns the list head, which is either the first allocated
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> or <code>rdf:nil</code> if the
        <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a> is empty. If a list element represents a <a href="#dfn-relative-iris" class="internalDFN" data-link-type="dfn">relative <abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
        the corresponding <code>rdf:first</code> triple is omitted.</p>
    </section>

    <section class="algorithm" id="algorithm-14">
      <h4 id="x8-3-2-algorithm"><span class="secno">8.3.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-14" aria-label="Permalink for 8.3.2 Algorithm" title="Permalink for 8.3.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes two inputs: an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>list</var>
        and an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>list triples</var> used for returning
        the generated <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triples</a>.</p>

      <ol>
        <li>If <var>list</var> is empty, return <code>rdf:nil</code>.</li>
        <li>Otherwise, create an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>bnodes</var> composed of a
          <a href="#generate-blank-node-identifier">newly generated blank node identifier</a>
          for each entry in <var>list</var>.</li>
        <li>Initialize an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>list triples</var>.</li>
        <li>For each pair of <var>subject</var> from <var>bnodes</var> and <var>item</var> from <var>list</var>:
          <ol>
            <li>Initialize <var>object</var> to the result of using the
              <a href="#object-to-rdf-conversion">Object to RDF Conversion algorithm</a>
              passing <var>item</var> to <var>list triples</var>.</li>
            <li>Unless <var>object</var> is <code>null</code>, append a <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a>
              composed of <var>subject</var>, <code>rdf:first</code>, and <var>object</var>.</li>
            <li>Set <var>rest</var> as the next entry in <var>bnodes</var>, or if that
              does not exist, <code>rdf:nil</code>. Append a
              <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a> composed of <var>subject</var>,
              <code>rdf:rest</code>, and <var>rest</var> to <var>list triples</var>.</li>
          </ol>
        </li>
        <li>Return the first <a href="#dfn-blank-nodes" class="internalDFN" data-link-type="dfn">blank node</a> from <var>bnodes</var> or
          <code>rdf:nil</code> if <var>bnodes</var> is empty.</li>
      </ol>
    </section>
  </section> <!-- end of List to RDF -->

  <section id="serialize-rdf-as-json-ld-algorithm">
    <h3 id="x8-4-serialize-rdf-as-json-ld-algorithm"><span class="secno">8.4 </span>Serialize RDF as JSON-LD Algorithm&nbsp;<span class="permalink"><a href="#serialize-rdf-as-json-ld-algorithm" aria-label="Permalink for 8.4 Serialize RDF as JSON-LD Algorithm" title="Permalink for 8.4 Serialize RDF as JSON-LD Algorithm"><span>§</span></a></span></h3>

    <p>This algorithm serializes an <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a> consisting of a
      <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a> and zero or more
      <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graphs</a> into a JSON-LD document.</p>

    <p>In the RDF abstract syntax, <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a> have a
      <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form"><dfn data-dfn-type="dfn" id="dfn-lexical-form">lexical form</dfn></a>, as defined
      in [<cite><a class="bibref" href="#bib-RDF11-CONCEPTS">RDF11-CONCEPTS</a></cite>]. The form of these literals is used when creating <a href="#dfn-json-ld-values" class="internalDFN" data-link-type="dfn">JSON-LD values</a> based on these literals.</p>

    <section class="informative" id="overview-15">
      <h4 id="x8-4-1-overview"><span class="secno">8.4.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-15" aria-label="Permalink for 8.4.1 Overview" title="Permalink for 8.4.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p>Iterate through each graph in the dataset, converting each
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a> into a <a href="#dfn-lists" class="internalDFN" data-link-type="dfn">list</a>
        and generating a JSON-LD document in expanded form for all
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a>, <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a>
        and <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a>.
        If the <var>use native types</var> flag is set to <code>true</code>,
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a> with a
        <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        that equals <code>xsd:integer</code> or <code>xsd:double</code> are converted
        to a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">JSON numbers</a> and <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a>
        with a <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        that equals <code>xsd:boolean</code> are converted to <code>true</code> or
        <code>false</code> based on their
        <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
        as described in
        <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>.
        Unless the <i>use <code>rdf:type</code></i> flag is set to true, <code>rdf:type</code>
        predicates will be serialized as <code>@type</code> as long as the associated object is
        either an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>.</p>
    </section>

    <section class="algorithm" id="algorithm-15">
      <h4 id="x8-4-2-algorithm"><span class="secno">8.4.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-15" aria-label="Permalink for 8.4.2 Algorithm" title="Permalink for 8.4.2 Algorithm"><span>§</span></a></span></h4>

      <p>The algorithm takes one required and two optional inputs: an <a href="#dfn-dataset" class="internalDFN" data-link-type="dfn">RDF dataset</a>  <var>dataset</var>
        and the two flags <var>use native types</var> and <i>use <code>rdf:type</code></i>
        that both default to <code>false</code>.</p>

      <ol>
        <li>Initialize <var>default graph</var> to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li>Initialize <var>graph map</var> to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting
          of a single member <code>@default</code> whose value references
          <var>default graph</var>.</li>
        <li>Initialize <var>node usage map</var> to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
        <li>For each <var>graph</var> in  <var>dataset</var>:
          <ol>
            <li>If <var>graph</var> is the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a>,
              set <var>name</var> to <code>@default</code>, otherwise to the
              <a href="#dfn-graph-names" class="internalDFN" data-link-type="dfn">graph name</a> associated with <var>graph</var>.</li>
            <li>If <var>graph map</var> has no <var>name</var> member, create one and set
              its value to an empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</li>
            <li>If <var>graph</var> is not the <a href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default graph</a> and
              <var>default graph</var> does not have a <var>name</var> member,
              create such a member and initialize its value to a new
              <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> with a single member <code>@id</code>
              whose value is <var>name</var>.</li>
            <li>Reference the value of the <var>name</var> member in <var>graph map</var>
              using the variable <var>node map</var>.</li>
            <li>For each <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a> in <var>graph</var>
              consisting of <var>subject</var>, <var>predicate</var>, and <var>object</var>:
              <ol>
                <li>If <var>node map</var> does not have a <var>subject</var> member,
                  create one and initialize its value to a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
                  consisting of a single member <code>@id</code> whose value is
                  set to <var>subject</var>.</li>
                <li>Reference the value of the <var>subject</var> member in <var>node map</var>
                  using the variable <var>node</var>.</li>
                <li>If <var>object</var> is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,
                  and <var>node map</var> does not have an <var>object</var> member,
                  create one and initialize its value to a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
                  consisting of a single member <code>@id</code> whose value is
                  set to <var>object</var>.</li>
                <li>If <var>predicate</var> equals <code>rdf:type</code>, the
                  <i>use <code>rdf:type</code></i> flag is not <code>true</code>, and <var>object</var>
                  is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,
                  append <var>object</var> to the value of the <code>@type</code>
                  member of <var>node</var>; unless such an item already exists.
                  If no such member exists, create one
                  and initialize it to an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> whose only item is
                  <var>object</var>. Finally, continue to the next
                  <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">RDF triple</a>.</li>
                <li>Set <var>value</var> to the result of using the
                  <a href="#rdf-to-object-conversion">RDF to Object Conversion algorithm</a>,
                  passing <var>object</var> and <var>use native types</var>.</li>
                <li>If <var>node</var> does not have an <var>predicate</var> member, create one
                  and initialize its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>If there is no item equivalent to <var>value</var> in the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                  associated with the <var>predicate</var> member of <var>node</var>, append a
                  reference to <var>value</var> to the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. Two JSON objects
                  are considered equal if they have equivalent key-value pairs.</li>
                <li>If <var>object</var> is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a> or <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>,
                  it might represent the list node:
                  <ol>
                    <li>If the <var>object</var> member of <var>node usage map</var> does not exist,
                      initialize it to a new empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                    <li>Append the value of the <code>@id</code> member of <code>node</code> to
                      the <var>object</var> member of <var>node usage map</var>.</li>
                    <li>If the <var>object</var> member of <var>node map</var> has no
                      <code>usages</code> member, create one and initialize it to
                      an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                    <li>Reference the <code>usages</code> member of the <var>object</var>
                      member of <var>node map</var> using the variable <var>usages</var>.</li>
                    <li>Append a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> consisting of three
                      members, <code>node</code>, <code>property</code>, and <code>value</code>
                      to the <var>usages</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>. The <code>node</code> member
                      is set to a reference to <var>node</var>, <code>property</code> to <var>predicate</var>,
                      and <code>value</code> to a reference to <var>value</var>.</li>
                  </ol>
                </li>
              </ol>
            </li>
          </ol>
        </li>
        <li>For each <var>name</var> and <var>graph object</var> in <var>graph map</var>:
          <ol>
            <li>If <var>graph object</var> has no <code>rdf:nil</code> member, continue
              with the next <var>name</var>-<var>graph object</var> pair as the graph does
              not contain any lists that need to be converted.</li>
            <li>Initialize <var>nil</var> to the value of the <code>rdf:nil</code> member
              of <var>graph object</var>.</li>
            <li>For each item <var>usage</var> in the <code>usages</code> member of
              <var>nil</var>, perform the following steps:
              <ol>
                <li>Initialize <var>node</var> to the value of the value of the
                  <code>node</code> member of <var>usage</var>, <var>property</var> to
                  the value of the <code>property</code> member of <var>usage</var>,
                  and <var>head</var> to the value of the <code>value</code> member
                  of <var>usage</var>.</li>
                <li>Initialize two empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">arrays</a> <var>list</var>
                  and <var>list nodes</var>.</li>
                <li>While <var>property</var> equals <code>rdf:rest</code>,
                  <span class="changed">the value of the <code>@id</code> member
                    of <var>node</var> is a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,</span>
                  the <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> value of the member of <var>node usage map</var> associated with the <code>@id</code>
                  member of <code>node</code> has only one member,
                  <span class="changed">
                    the value associated to the <code>usages</code> member of <i>node</i> has
                    exactly 1 entry,</span>
                  <var>node</var> has a <code>rdf:first</code> and <code>rdf:rest</code> property,
                  both of which have as value an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> consisting of a single element,
                  and <var>node</var> has no other members apart from an optional <code>@type</code>
                  member whose value is an array with a single item equal to
                  <code>rdf:List</code>,
                  <var>node</var> represents a well-formed list node.
                  Perform the following steps to traverse the list backwards towards its head:
                  <ol>
                    <li>Append the only item of <code>rdf:first</code> member of
                      <var>node</var> to the <var>list</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                    <li>Append the value of the <code>@id</code> member of
                      <var>node</var> to the <var>list nodes</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                    <li>Initialize <var>node usage</var> to the only item of the
                      <code>usages</code> member of <var>node</var>.</li>
                    <li>Set <var>node</var> to the value of the <code>node</code> member
                      of <var>node usage</var>, <var>property</var> to the value of the
                      <code>property</code> member of <var>node usage</var>, and
                      <var>head</var> to the value of the <code>value</code> member
                      of <var>node usage</var>.</li>
                    <li>If the <code>@id</code> member of <var>node</var> is an
                      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> instead of a <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>,
                      exit the while loop.</li>
                  </ol>
                </li>
                <li>If <var>property</var> equals <code>rdf:first</code>, i.e., the
                  detected list is nested inside another list
                  <ol>
                    <li>and the value of the <code>@id</code> of <var>node</var> equals
                      <code>rdf:nil</code>, i.e., the detected list is empty,
                      continue with the next <var>usage</var> item. The
                      <code>rdf:nil</code> node cannot be converted to a
                      <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a> as it would result in a list of
                      lists, which isn't supported.</li>
                    <li>Otherwise, the list consists of at least one item. We preserve the
                      head node and transform the rest of the linked list to a
                      <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a>.</li>
                    <li>Set <var>head id</var> to the value of the <code>@id</code>
                      member of <var>head</var>.</li>
                    <li>Set <var>head</var> to the value of the <var>head id</var> member of
                      <var>graph object</var> so that all it's properties can be accessed.</li>
                    <li>Then, set <var>head</var> to the only item in the value of the
                      <code>rdf:rest</code> member of <var>head</var>.</li>
                    <li>Finally, remove the last item of the <var>list</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
                      and the last item of the <var>list nodes</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                  </ol>
                </li>
                <li>Remove the <code>@id</code> member from <var>head</var>.</li>
                <li>Reverse the order of the <var>list</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>Add an <code>@list</code> member to <var>head</var> and initialize
                  its value to the <var>list</var> <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>For each item <var>node id</var> in <var>list nodes</var>, remove the
                  <var>node id</var> member from <var>graph object</var>.</li>
              </ol>
            </li>
          </ol>
        </li>
        <li>Initialize an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> <var>result</var>.</li>
        <li>For each <var>subject</var> and <var>node</var> in <var>default graph</var>
          ordered by <var>subject</var>:
          <ol>
            <li>If <var>graph map</var> has a <var>subject</var> member:
              <ol>
                <li>Add an <code>@graph</code> member to <var>node</var> and initialize
                  its value to an empty <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>.</li>
                <li>For each key-value pair <var>s</var>-<var>n</var> in the <var>subject</var>
                  member of <var>graph map</var> ordered by <var>s</var>, append <var>n</var>
                  to the <code>@graph</code> member of <var>node</var> after
                  removing its <code>usages</code> member, unless the only
                  remaining member of <var>n</var> is <code>@id</code>.</li>
              </ol>
            </li>
            <li>Append <var>node</var> to <var>result</var> after removing its
              <code>usages</code> member, unless the only remaining member of
              <var>node</var> is <code>@id</code>.</li>
          </ol>
        </li>
        <li>Return <var>result</var>.</li>
      </ol>
    </section>
  </section> <!-- end of Serialize RDF as JSON-LD Algorithm -->

  <section id="rdf-to-object-conversion">
    <h3 id="x8-5-rdf-to-object-conversion"><span class="secno">8.5 </span>RDF to Object Conversion&nbsp;<span class="permalink"><a href="#rdf-to-object-conversion" aria-label="Permalink for 8.5 RDF to Object Conversion" title="Permalink for 8.5 RDF to Object Conversion"><span>§</span></a></span></h3>

    <p>This algorithm transforms an RDF literal to a JSON-LD <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a>
      and a RDF blank node or <abbr title="Internationalized Resource Identifier">IRI</abbr> to an JSON-LD <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>.</p>

    <section class="informative" id="overview-16">
      <h4 id="x8-5-1-overview"><span class="secno">8.5.1 </span>Overview&nbsp;<span class="permalink"><a href="#overview-16" aria-label="Permalink for 8.5.1 Overview" title="Permalink for 8.5.1 Overview"><span>§</span></a></span></h4><p><em>This section is non-normative.</em></p>

      <p><a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a> are transformed to
        <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value objects</a> whereas <a href="#dfn-iris" class="internalDFN" data-link-type="dfn">IRIs</a> and
        <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifiers</a> are
        transformed to <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a>.
        If the <var>use native types</var> flag is set to <code>true</code>,
        <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a> with a
        <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        that equals <code>xsd:integer</code> or <code>xsd:double</code> are converted
        to a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">JSON numbers</a> and <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a>
        with a <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
        that equals <code>xsd:boolean</code> are converted to <code>true</code> or
        <code>false</code> based on their
        <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
        as described in
        <a class="sectionRef sec-ref" href="#data-round-tripping">section <span class="secno">8.6</span> <span class="sec-title">Data Round Tripping</span></a>.</p>
    </section>

    <section class="algorithm" id="algorithm-16">
      <h4 id="x8-5-2-algorithm"><span class="secno">8.5.2 </span>Algorithm&nbsp;<span class="permalink"><a href="#algorithm-16" aria-label="Permalink for 8.5.2 Algorithm" title="Permalink for 8.5.2 Algorithm"><span>§</span></a></span></h4>

      <p>This algorithm takes two required inputs: a <var>value</var> to be converted
        to a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> and a flag <var>use native types</var>.</p>

      <ol>
        <li>If <var>value</var> is an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> or a
          <a href="#dfn-blank-node-identifiers" class="internalDFN" data-link-type="dfn">blank node identifier</a>, return a new <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
          consisting of a single member <code>@id</code> whose value is set to
          <var>value</var>.</li>
        <li>Otherwise <var>value</var> is an
          <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literal</a>:
          <ol>
            <li>Initialize a new empty <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> result.</li>
            <li>Initialize <var>converted value</var> to <var>value</var>.</li>
            <li>Initialize <var>type</var> to <code>null</code></li>
            <li>If <var>use native types</var> is <code>true</code>
              <ol>
                <li>If the
                  <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
                  of <var>value</var> equals <code>xsd:string</code>, set
                  <var>converted value</var> to the
                  <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
                  of <var>value</var>.</li>
                <li>Otherwise, if the
                  <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
                  of <var>value</var> equals <code>xsd:boolean</code>, set
                  <var>converted value</var> to <code>true</code> if the
                  <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
                  of <var>value</var> matches <code>true</code>, or <code>false</code>
                  if it matches <code>false</code>. If it matches neither,
                  set <var>type</var> to <code>xsd:boolean</code>.</li>
                <li>Otherwise, if the
                  <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
                  of <var>value</var> equals <code>xsd:integer</code> or
                  <code>xsd:double</code> and its
                  <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
                  is a valid <code>xsd:integer</code> or <code>xsd:double</code>
                  according [<cite><a class="bibref" href="#bib-XMLSCHEMA11-2">XMLSCHEMA11-2</a></cite>], set <var>converted value</var>
                  to the result of converting the
                  <a href="#dfn-lexical-form" class="internalDFN" data-link-type="dfn">lexical form</a>
                  to a JSON <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>.</li>
              </ol>
            </li>
            <li>Otherwise, if <var>value</var> is a
              <a href="#dfn-language-tagged-strings" class="internalDFN" data-link-type="dfn">language-tagged string</a>
              add a member <code>@language</code> to <var>result</var> and set its value to the
              <a href="#dfn-language-tag" class="internalDFN" data-link-type="dfn">language tag</a> of <var>value</var>.</li>
            <li>Otherwise, set <var>type</var> to the
              <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
              of <var>value</var>, unless it equals <code>xsd:string</code> which is ignored.</li>
            <li>Add a member <code>@value</code> to <var>result</var> whose value
              is set to <var>converted value</var>.</li>
            <li>If <var>type</var> is not <code>null</code>, add a member <code>@type</code>
              to <var>result</var> whose value is set to <var>type</var>.</li>
            <li>Return <var>result</var>.</li>
          </ol>
        </li>
      </ol>
    </section>
  </section>

  <section id="data-round-tripping">
    <h3 id="x8-6-data-round-tripping"><span class="secno">8.6 </span>Data Round Tripping&nbsp;<span class="permalink"><a href="#data-round-tripping" aria-label="Permalink for 8.6 Data Round Tripping" title="Permalink for 8.6 Data Round Tripping"><span>§</span></a></span></h3>

    <p>When <a href="#deserialize-json-ld-to-rdf-algorithm">deserializing JSON-LD to RDF</a>
      JSON-native <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a> are automatically
      type-coerced to <code>xsd:integer</code> or <code>xsd:double</code>
      depending on whether the <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> has a non-zero fractional part
      or not (the result of a modulo‑1 operation), the boolean values
      <code>true</code> and <code>false</code> are coerced to <code>xsd:boolean</code>,
      and <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a> are coerced to <code>xsd:string</code>.
      The numeric or boolean values themselves are converted to
      <dfn data-dfn-type="dfn" id="dfn-canonical-lexical-form">canonical lexical form</dfn>, i.e., a deterministic string
      representation as defined in [<cite><a class="bibref" href="#bib-XMLSCHEMA11-2">XMLSCHEMA11-2</a></cite>].</p>

    <p>The <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> of an <em>integer</em>, i.e., a
      <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> with no non-zero fractional part or a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>
      coerced to <code>xsd:integer</code>, is a finite-length sequence of decimal
      digits (<code>0-9</code>) with an optional leading minus sign; leading
      zeros are prohibited. In JavaScript, implementers can use the following
      snippet of code to convert an integer to
      <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a>:</p>

    <div class="example"><div class="example-title marker"><span>Example 20</span><span style="text-transform: none">: Sample integer serialization implementation in JavaScript</span></div><pre class="nohighlight" data-ignore="">(value).toFixed(0).toString()</pre></div>

    <p>The <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> of a <em>double</em>, i.e., a
      <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> with a non-zero fractional part or a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>
      coerced to <code>xsd:double</code>, consists of a mantissa followed by the
      character <code>E</code>, followed by an exponent. The mantissa is a
      decimal number and the exponent is an integer. Leading zeros and a
      preceding plus sign (<code>+</code>) are prohibited in the exponent.
      If the exponent is zero, it is indicated by <code>E0</code>. For the
      mantissa, the preceding optional plus sign is prohibited and the
      decimal point is required. Leading and trailing zeros are prohibited
      subject to the following: number representations must be normalized
      such that there is a single digit which is non-zero to the left of
      the decimal point and at least a single digit to the right of the
      decimal point unless the value being represented is zero. The
      canonical representation for zero is <code>0.0E0</code>.
      <code>xsd:double</code>'s value space is defined by the IEEE
      double-precision 64-bit floating point type [<cite><a class="bibref" href="#bib-IEEE-754-2008">IEEE-754-2008</a></cite>] whereas
      the value space of JSON <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a> is not
      specified; when deserializing JSON-LD to RDF the mantissa is rounded to
      15&nbsp;digits after the decimal point. In JavaScript, implementers
      can use the following snippet of code to convert a double to
      <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a>:</p>

    <div class="example"><div class="example-title marker"><span>Example 21</span><span style="text-transform: none">: Sample floating point number serialization implementation in JavaScript</span></div><pre class="nohighlight" data-ignore="">(value).toExponential(15).replace(/(\d)0*e\+?/,'$1E')</pre></div>

    <p>The <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a> of the <em>boolean</em>
      values <code>true</code> and <code>false</code> are the strings
      <code>true</code> and <code>false</code>.</p>

    <p>When JSON-native <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a> are deserialized
      to RDF, lossless data round-tripping cannot be guaranteed, as rounding
      errors might occur. When
      <a href="#serialize-rdf-as-json-ld-algorithm">serializing RDF as JSON-LD</a>,
      similar rounding errors might occur. Furthermore, the datatype or the lexical
      representation might be lost. An <code>xsd:double</code> with a value
      of <code>2.0</code> will, e.g., result in an <code>xsd:integer</code>
      with a value of <code>2</code> in <a href="#dfn-canonical-lexical-form" class="internalDFN" data-link-type="dfn">canonical lexical form</a>
      when converted from RDF to JSON-LD and back to RDF. It is important
      to highlight that in practice it might be impossible to losslessly
      convert an <code>xsd:integer</code> to a <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a> because
      its value space is not limited. While the JSON specification [<cite><a class="bibref" href="#bib-RFC7159">RFC7159</a></cite>]
      does not limit the value space of <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">numbers</a>
      either, concrete implementations typically do have a limited value
      space.</p>

    <p>To ensure lossless round-tripping the
      <a href="#serialize-rdf-as-json-ld-algorithm">Serialize RDF as JSON-LD algorithm</a>
      specifies a <var>use native types</var> flag which controls whether
      <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF literals</a>
      with a <a href="#dfn-datatype-iri" class="internalDFN" data-link-type="dfn">datatype <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
      equal to <code>xsd:integer</code>, <code>xsd:double</code>, or
      <code>xsd:boolean</code> are converted to their JSON-native
      counterparts. If the <var>use native types</var> flag is set to
      <code>false</code>, all literals remain in their original string
      representation.</p>

    <p>Some JSON serializers, such as PHP's native implementation in some versions,
      backslash-escape the forward slash character. For example, the value
      <code>http://example.com/</code> would be serialized as <code>http:\/\/example.com\/</code>.
      This is problematic as other JSON parsers might not understand those escaping characters.
      There is no need to backslash-escape forward slashes in JSON-LD. To aid
      interoperability between JSON-LD processors, forward slashes <em class="rfc2119" title="MUST NOT">MUST NOT</em> be
      backslash-escaped.</p>
  </section> <!-- end of Data Round Tripping -->
</section>


<section id="the-application-programming-interface">
  <!--OddPage--><h2 id="x9-the-application-programming-interface"><span class="secno">9. </span>The Application Programming Interface&nbsp;<span class="permalink"><a href="#the-application-programming-interface" aria-label="Permalink for 9. The Application Programming Interface" title="Permalink for 9. The Application Programming Interface"><span>§</span></a></span></h2>

  <p>This API provides a clean mechanism that enables developers to convert
    JSON-LD data into a variety of output formats that are often easier to
    work with.</p>

  <p>The JSON-LD API uses <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promises</a> to represent
    the result of the various asynchronous operations.
    <a href="http://www.ecma-international.org/ecma-262/6.0/index.html#sec-promise-objects">Promises</a> are defined in [<cite><a class="bibref" href="#bib-ECMASCRIPT-6.0">ECMASCRIPT-6.0</a></cite>].
    General use within specifications can be found in [<cite><a class="bibref" href="#bib-promises-guide">promises-guide</a></cite>].</p>

  <section id="the-jsonldprocessor-interface">
    <h3 id="x9-1-the-jsonldprocessor-interface"><span class="secno">9.1 </span>The <dfn data-dfn-type="dfn" id="dom-jsonldprocessor" data-idl="" data-title="JsonLdProcessor" data-dfn-for=""><code>JsonLdProcessor</code></dfn> Interface&nbsp;<span class="permalink"><a href="#the-jsonldprocessor-interface" aria-label="Permalink for 9.1 The JsonLdProcessor Interface" title="Permalink for 9.1 The JsonLdProcessor Interface"><span>§</span></a></span></h3>

    <p>The <a href="#dom-jsonldprocessor" class="internalDFN" data-link-type="dfn"><code>JsonLdProcessor</code></a> interface is the high-level programming structure
      that developers use to access the JSON-LD transformation methods.</p>

    <p>It is important to highlight that implementations do not modify the input parameters.
      If an error is detected, the <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> is
      rejected passing a <a href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a> with the corresponding error
      <a data-link-for="JsonLdError" href="#dom-jsonlderror-code" class="internalDFN" data-link-type="dfn"><code>code</code></a>
      and processing is stopped.</p>

    <p>If the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-documentloader" class="internalDFN" data-link-type="dfn"><code>documentLoader</code></a>
      option is specified, it is used to dereference remote documents and contexts.
      The <a data-link-for="RemoteDocument" href="#dom-remotedocument-documenturl" class="internalDFN" data-link-type="dfn"><code>documentUrl</code></a>
      in the returned <a href="#dom-remotedocument" class="internalDFN" data-link-type="dfn"><code>RemoteDocument</code></a>
      is used as <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> and the
      <a data-link-for="RemoteDocument" href="#dom-remotedocument-contexturl" class="internalDFN" data-link-type="dfn"><code>contextUrl</code></a>
      is used instead of looking at the HTTP Link Header directly. For the sake of simplicity, none of the algorithms
      in this document mention this directly.</p>

    <div><pre class="def idl"><span class="idlInterface" id="idl-def-jsonldprocessor" data-idl="" data-title="JsonLdProcessor">[<span class="idlCtor"><span class="extAttrName"><a href="https://heycam.github.io/webidl/#Constructor">Constructor</a></span></span>]
interface <span class="idlInterfaceID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldprocessor" class="internalDFN" data-link-type="dfn"><code>JsonLdProcessor</code></a></span> {
<span class="idlMethod" id="idl-def-jsonldprocessor-compact-input-context-options" data-idl="" data-title="compact" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;</span>           <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="compact|compact()" href="#dom-jsonldprocessor-compact" class="internalDFN" data-link-type="dfn"><code>compact</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                       <span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a></span> <span class="idlParamName">context</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod" id="idl-def-jsonldprocessor-expand-input-options" data-idl="" data-title="expand" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;&gt;</span> <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="expand|expand()" href="#dom-jsonldprocessor-expand" class="internalDFN" data-link-type="dfn"><code>expand</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                      <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod" id="idl-def-jsonldprocessor-flatten-input-context-options" data-idl="" data-title="flatten" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;</span>           <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="flatten|flatten()" href="#dom-jsonldprocessor-flatten" class="internalDFN" data-link-type="dfn"><code>flatten</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a>?</span> <span class="idlParamName">context</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
};</span></pre></div>

    <dl data-sort=""><dt><dfn data-dfn-for="jsonldprocessor" data-dfn-type="dfn" id="dom-jsonldprocessor-compact" data-idl="" data-title="compact" data-lt="compact|compact()"><code>compact</code></dfn></dt><dd>
      </dd><dd class="algorithm">
        <p><a href="#dfn-compact" class="internalDFN" data-link-type="dfn">Compacts</a> the given <var>input</var> using the
          <var>context</var> according to the steps in the
          <a href="#compaction-algorithm">Compaction algorithm</a>:</p>

        <ol>
          <li>Create a new <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> <var>promise</var> and return it. The
            following steps are then executed asynchronously.</li>
          <li>Set <var>expanded input</var> to the result of using the
            <a data-link-for="JsonLdProcessor" href="#dom-jsonldprocessor-expand" class="internalDFN" data-link-type="dfn"><code>expand</code></a>
            method using <a data-lt="jsonldprocessor-compact-input" href="#dfn-jsonldprocessor-compact-input" class="internalDFN" data-link-type="dfn">input</a> and <a data-lt="jsonldprocessor-compact-options" href="#dfn-jsonldprocessor-compact-options" class="internalDFN" data-link-type="dfn">options</a>.
          </li><li>If <a data-lt="jsonldprocessor-compact-context" href="#dfn-jsonldprocessor-compact-context" class="internalDFN" data-link-type="dfn">context</a> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> having an <code>@context</code> member, set
            <var>context</var> to that member's value, otherwise to <a data-lt="jsonldprocessor-compact-context" href="#dfn-jsonldprocessor-compact-context" class="internalDFN" data-link-type="dfn">context</a>.</li>
          <li class="changed">Initialize an <var>active context</var> using <var>context</var>;
            the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is set to
            the <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a> option from
            <a data-lt="jsonldprocessor-compact-options" href="#dfn-jsonldprocessor-compact-options" class="internalDFN" data-link-type="dfn">options</a>, if set;
            otherwise, if the
            <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a> option is
            <strong>true</strong>, to the <abbr title="Internationalized Resource Identifier">IRI</abbr> of the currently being processed
            document, if available; otherwise to <code>null</code>.</li>
          <li>Set <var>compacted output</var> to the result of using the
            <a href="#compaction-algorithm">Compaction algorithm</a>, using <a href="#dfn-active-context" class="internalDFN" data-link-type="dfn">active context</a>,
            an empty <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> as <var>inverse context</var>,
            <code>null</code> as <var>property</var>,
            <var>expanded input</var> as <var>element</var>, and if passed, the
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a> flag in <a data-lt="jsonldprocessor-compact-options" href="#dfn-jsonldprocessor-compact-options" class="internalDFN" data-link-type="dfn">options</a>.</li>
          <li>Fulfill the <var>promise</var> passing <var>compacted output</var>.
            <span class="changed">transforming <var>compacted output</var> from the
              <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a> to a JSON serialization</span>.</li>
        </ol>

        <dl class="parameters">
          <dt><dfn data-lt="jsonldprocessor-compact-input" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-compact-input">input</dfn></dt>
           <dd>The <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, array of <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> to perform the compaction upon or an
            <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the JSON-LD document to compact.</dd>
          <dt><dfn data-lt="jsonldprocessor-compact-context" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-compact-context">context</dfn></dt>
          <dd>The context to use when <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> the <code>input</code>;
            it can be specified by using a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, an
            <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or an array consisting of
            <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> and <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>s.</dd>
          <dt><dfn data-lt="jsonldprocessor-compact-options" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-compact-options">options</dfn></dt>
          <dd>A set of options to configure the algorithms. This allows, e.g.,
            to set the input document's base <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
        </dl>
      </dd>

      <dt><dfn data-dfn-for="jsonldprocessor" data-dfn-type="dfn" id="dom-jsonldprocessor-expand" data-idl="" data-title="expand" data-lt="expand|expand()"><code>expand</code></dfn></dt>
      <dd class="algorithm">
        <p><a href="#expansion">Expands</a> the given <a data-lt="jsonldprocessor-expand-input" href="#dfn-jsonldprocessor-expand-input" class="internalDFN" data-link-type="dfn">input</a> according to
          the steps in the <a href="#expansion-algorithm">Expansion algorithm</a>:</p>

        <ol>
          <li>Create a new <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> <var>promise</var> and return it. The
            following steps are then executed asynchronously.</li>
          <li>If the passed <a data-lt="jsonldprocessor-expand-input" href="#dfn-jsonldprocessor-expand-input" class="internalDFN" data-link-type="dfn">input</a> is a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>
            representing the <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> of a remote document, dereference it.
            If the retrieved document's content type is neither <code>application/json</code>,
            nor <code>application/ld+json</code>, nor any other media type using a
            <code>+json</code> suffix as defined in [<cite><a class="bibref" href="#bib-RFC6839">RFC6839</a></cite>], reject the <var>promise</var> passing an
            <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-loading-document-failed" class="internalDFN" data-link-type="dfn"><code>loading document failed</code></a>
            error.</li>
          <li>Initialize a new empty <var>active context</var>. The <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>
            of the <var>active context</var> is set to the <abbr title="Internationalized Resource Identifier">IRI</abbr> of the currently being processed
            document, if available; otherwise to <code>null</code>. If set, the
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a> option from <a data-lt="jsonldprocessor-expand-options" href="#dfn-jsonldprocessor-expand-options" class="internalDFN" data-link-type="dfn">options</a> overrides the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</li>
          <li>If an
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-expandcontext" class="internalDFN" data-link-type="dfn"><code>expandContext</code></a> option
            has been passed, update the <var>active context</var> using the
            <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-expandcontext" class="internalDFN" data-link-type="dfn"><code>expandContext</code></a>
            as <var>local context</var>. If
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-expandcontext" class="internalDFN" data-link-type="dfn"><code>expandContext</code></a>
            is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> having an <code>@context</code> member, pass that member's value instead.</li>
          <li>Once <a data-lt="jsonldprocessor-expand-input" href="#dfn-jsonldprocessor-expand-input" class="internalDFN" data-link-type="dfn">input</a> has been retrieved, the response has an HTTP Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>]
            using the <code>http://www.w3.org/ns/json-ld#context</code> link relation
            and a content type of <code>application/json</code> or any media type
            with a <code>+json</code> suffix as defined in [<cite><a class="bibref" href="#bib-RFC6839">RFC6839</a></cite>] except
            <code>application/ld+json</code>, update the <var>active context</var> using the
            <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
            context referenced in the HTTP Link Header as <var>local context</var>. The
            HTTP Link Header is ignored for documents served as <code>application/ld+json</code> If
            multiple HTTP Link Headers using the <code>http://www.w3.org/ns/json-ld#context</code>
            link relation are found, the <var>promise</var> is rejected with a <a href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a> whose code is set to
            <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-multiple-context-link-headers" class="internalDFN" data-link-type="dfn"><code>multiple context link headers</code></a>
            and processing is terminated.</li>
          <li class="changed">If necessary, transform <var>input</var> into the
            <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>. If <var>input</var> cannot be transformed to the
            <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>, reject <var>promise</var> passing a
            <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-loading-document-failed" class="internalDFN" data-link-type="dfn"><code>loading document failed</code></a> error.</li>
          <li>Set <var>expanded output</var> to the result of using the
            <a href="#expansion-algorithm">Expansion algorithm</a>, passing the
            <var>active context</var> and <var>input</var> as <var>element</var>,
            <span class="changed">and, if the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-frameexpansion" class="internalDFN" data-link-type="dfn"><code>frameExpansion</code></a> option is set, pass the <var>frame expansion</var> flag as <code>true</code>.</span>.</li>
          <li>Fulfill the <var>promise</var> passing <var>expanded output</var>.
            <span class="changed">transforming <var>expanded output</var> from the
              <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a> to a JSON serialization</span>.</li>
        </ol>

        <dl class="parameters">
          <dt><dfn data-lt="jsonldprocessor-expand-input" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-expand-input">input</dfn></dt>
          <dd>The <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> or array of <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> to perform the expansion upon or an
            <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> referencing the <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD document</a> to expand.</dd>
          <dt><dfn data-lt="jsonldprocessor-expand-options" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-expand-options">options</dfn></dt>
          <dd>A set of options to configure the used algorithms such. This allows, e.g.,
            to set the input document's <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
        </dl>
      </dd>

      <dt><dfn data-dfn-for="jsonldprocessor" data-dfn-type="dfn" id="dom-jsonldprocessor-flatten" data-idl="" data-title="flatten" data-lt="flatten|flatten()"><code>flatten</code></dfn></dt>
      <dd class="algorithm">
        <p><a href="#flattening">Flattens</a> the given <a data-lt="jsonldprocessor-flatten-input" href="#dfn-jsonldprocessor-flatten-input" class="internalDFN" data-link-type="dfn">input</a> and
          <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacts</a> it using the passed <a data-lt="jsonldprocessor-flatten-context" href="#dfn-jsonldprocessor-flatten-context" class="internalDFN" data-link-type="dfn">context</a>
          according to the steps in the <a href="#flattening-algorithm">Flattening algorithm</a>:</p>

        <ol>
          <li>Create a new <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> <var>promise</var> and return it. The
            following steps are then executed asynchronously.</li>
          <li>Set <var>expanded input</var> to the result of using the
            <a data-link-for="JsonLdProcessor" href="#dom-jsonldprocessor-expand" class="internalDFN" data-link-type="dfn"><code>expand</code></a>
            method using <a data-lt="jsonldprocessor-flatten-input" href="#dfn-jsonldprocessor-flatten-input" class="internalDFN" data-link-type="dfn">input</a> and <a data-lt="jsonldprocessor-flatten-options" href="#dfn-jsonldprocessor-flatten-options" class="internalDFN" data-link-type="dfn">options</a>.
          </li><li>If <a data-lt="jsonldprocessor-flatten-context" href="#dfn-jsonldprocessor-flatten-context" class="internalDFN" data-link-type="dfn">context</a> is a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> having an <code>@context</code> member, set
            <var>context</var> to that member's value, otherwise to <a data-lt="jsonldprocessor-flatten-context" href="#dfn-jsonldprocessor-flatten-context" class="internalDFN" data-link-type="dfn">context</a>.</li>
          <li class="changed">Initialize an <var>active context</var> using <var>context</var>;
            the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> is set to
            the <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a> option from
            <a data-lt="jsonldprocessor-flatten-options" href="#dfn-jsonldprocessor-flatten-options" class="internalDFN" data-link-type="dfn">options</a>, if set;
            otherwise, if the
            <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a> option is
            <strong>true</strong>, to the <abbr title="Internationalized Resource Identifier">IRI</abbr> of the currently being processed
            document, if available; otherwise to <code>null</code>.</li>
          <li>Initialize an empty <var>identifier map</var> and a <var>counter</var> (set to <code>0</code>)
            to be used by the
            <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>.</li>
          <li>Set <var>flattened output</var> to the result of using the
            <a href="#flattening-algorithm">Flattening algorithm</a>, passing
            <var>expanded input</var> as <var>element</var>, <var>active context</var>, and if passed, the
            <a data-link-for="JsonldOptions" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a> flag in <a data-lt="jsonldprocessor-flatten-options" href="#dfn-jsonldprocessor-flatten-options" class="internalDFN" data-link-type="dfn">options</a>
            (which is internally passed to the
            <a href="#compaction-algorithm">Compaction algorithm</a>).</li>
          <li>Fulfill the <var>promise</var> passing <var>flattened output</var>.
            <span class="changed">transforming <var>flattened output</var> from the
              <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a> to a JSON serialization</span>.</li>
        </ol>

        <dl class="parameters">
          <dt><dfn data-lt="jsonldprocessor-flatten-input" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-flatten-input">input</dfn></dt>
           <dd>The <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a> or array of <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a> or an <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>
            referencing the JSON-LD document to flatten.</dd>
          <dt><dfn data-lt="jsonldprocessor-flatten-context" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-flatten-context">context</dfn></dt>
          <dd>The context to use when <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> the flattened <var>expanded input</var>;
            it can be specified by using a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, an
            <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or an array consisting of <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>
            and <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>s. If not
            passed or <code>null</code> is passed, the result will not be compacted
            but kept in expanded form.</dd>
          <dt><dfn data-lt="jsonldprocessor-flatten-options" data-lt-nodefault="" data-dfn-type="dfn" id="dfn-jsonldprocessor-flatten-options">options</dfn></dt>
          <dd>A set of options to configure the used algorithms such. This allows, e.g.,
            to set the input document's <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
        </dl>
      </dd></dl>

    <div><pre class="def idl changed"><span class="idlDictionary" id="idl-def-jsonlddictionary" data-idl="" data-title="JsonLdDictionary">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a></span> {
};</span></pre></div>
    <p class="changed">The <dfn data-dfn-type="dfn" id="dom-jsonlddictionary" data-idl="" data-title="JsonLdDictionary" data-dfn-for=""><code>JsonLdDictionary</code></dfn> is the definition of a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>
      used to contain arbitrary key/value pairs which are the result of
      parsing a <a href="#dfn-json-objects" class="internalDFN" data-link-type="dfn">JSON Object</a>.

    </p><div><pre class="def idl changed"><span class="idlTypedef" id="idl-def-jsonldinput" data-idl="" data-title="JsonLdInput">typedef <span class="idlTypedefType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt; or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)</span> <span class="idlTypedefID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span>;</span></pre></div>

    <p class="changed">The <dfn data-dfn-type="dfn" id="dom-jsonldinput" data-idl="" data-title="JsonLdInput" data-dfn-for=""><code>JsonLdInput</code></dfn> type is used to refer to an input value that
      that may be a <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, an array of <a data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries </a> or a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> representing an
      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a> which an be dereferenced to retrieve a valid JSON document.</p>

    <div><pre class="def idl"><span class="idlTypedef" id="idl-def-jsonldcontext" data-idl="" data-title="JsonLdContext">typedef <span class="idlTypedefType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a> or <a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)&gt;)</span> <span class="idlTypedefID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a></span>;</span></pre></div>

    <p>The <dfn data-dfn-type="dfn" id="dom-jsonldcontext" data-idl="" data-title="JsonLdContext" data-dfn-for=""><code>JsonLdContext</code></dfn> type is used to refer to a value that
      that may be a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>, a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> representing an
      <a href="#dfn-iris" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr></a>, or an array of <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionaries</a>
      and <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>.</p>
  </section> <!-- end of JsonLdProcessor -->

  <section id="the-jsonldoptions-type">
    <h3 id="x9-2-the-jsonldoptions-type"><span class="secno">9.2 </span>The JsonLdOptions Type&nbsp;<span class="permalink"><a href="#the-jsonldoptions-type" aria-label="Permalink for 9.2 The JsonLdOptions Type" title="Permalink for 9.2 The JsonLdOptions Type"><span>§</span></a></span></h3>

    <p>The <dfn data-dfn-type="dfn" id="dom-jsonldoptions" data-idl="" data-title="JsonLdOptions" data-dfn-for=""><code>JsonLdOptions</code></dfn> type is used to pass various options to the
      <a href="#dom-jsonldprocessor" class="internalDFN" data-link-type="dfn"><code>JsonLdProcessor</code></a> methods.</p>

    <div><pre class="def idl"><span class="idlDictionary" id="idl-def-jsonldoptions" data-idl="" data-title="JsonLdOptions">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a></span> {
<span class="idlMember" id="idl-def-jsonldoptions-base" data-idl="" data-title="base" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>?</span>                       <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a></span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-compactarrays" data-idl="" data-title="compactArrays" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a></span> = <span class="idlMemberValue">true</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-compacttorelative" data-idl="" data-title="compactToRelative" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a></span> = <span class="idlMemberValue">true</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-documentloader" data-idl="" data-title="documentLoader" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a></span>             <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-documentloader" class="internalDFN" data-link-type="dfn"><code>documentLoader</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-expandcontext" data-idl="" data-title="expandContext" data-dfn-for="jsonldoptions">    <span class="idlMemberType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>? or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)</span> <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-expandcontext" class="internalDFN" data-link-type="dfn"><code>expandContext</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-frameexpansion" data-idl="" data-title="frameExpansion" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-frameexpansion" class="internalDFN" data-link-type="dfn"><code>frameExpansion</code></a></span> = <span class="idlMemberValue">false</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-processingmode" data-idl="" data-title="processingMode" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span>                        <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" id="idl-def-jsonldoptions-producegeneralizedrdf" data-idl="" data-title="produceGeneralizedRdf" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-producegeneralizedrdf" class="internalDFN" data-link-type="dfn"><code>produceGeneralizedRdf</code></a></span> = <span class="idlMemberValue">true</span>;</span>
};</span></pre></div>

    <dl data-sort=""><dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-base" data-idl="" data-title="base"><code>base</code></dfn></dt>
      <dd>The base <abbr title="Internationalized Resource Identifier">IRI</abbr> to use when expanding or <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a> the document. If set, this overrides
        the input document's <abbr title="Internationalized Resource Identifier">IRI</abbr>.</dd>
      <dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-compactarrays" data-idl="" data-title="compactArrays"><code>compactArrays</code></dfn></dt>
      <dd>If set to <code>true</code>, the JSON-LD processor replaces arrays with just
        one element with that element during <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compaction</a>. If set to <code>false</code>,
        all arrays will remain arrays even if they have just one element.
      </dd>
      <dt class="changed"><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-compacttorelative" data-idl="" data-title="compactToRelative"><code>compactToRelative</code></dfn></dt>
      <dd class="changed">Determines if IRIs are compacted relative to the
        <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a> option or document location when <a href="#dfn-compact" class="internalDFN" data-link-type="dfn">compacting</a>.</dd>
      <dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-documentloader" data-idl="" data-title="documentLoader"><code>documentLoader</code></dfn></dt>
      <dd>The callback of the loader to be used to retrieve remote documents and contexts.
        If specified, it is used to retrieve remote documents and contexts; otherwise,
        if not specified, the processor's built-in loader is used.</dd>
      <dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-expandcontext" data-idl="" data-title="expandContext"><code>expandContext</code></dfn></dt>
      <dd>A context that is used to initialize the active context when expanding a document.</dd>
      <dt class="changed"><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-frameexpansion" data-idl="" data-title="frameExpansion"><code>frameExpansion</code></dfn></dt>
      <dd class="changed">Enables special frame processing rules for the <a href="#expansion-algorithm">Expansion Algorithm</a>.</dd><dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-processingmode" data-idl="" data-title="processingMode"><code>processingMode</code></dfn></dt>
      <dd>Sets the <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>.
        If set to <code>json-ld-1.0</code> or <code>json-ld-1.1</code>, the
        implementation must produce exactly the same results as the algorithms
        defined in this specification.
        If set to another value, the JSON-LD processor is allowed to extend
        or modify the algorithms defined in this specification to enable
        application-specific optimizations. The definition of such
        optimizations is beyond the scope of this specification and thus
        not defined. Consequently, different implementations may implement
        different optimizations. Developers must not define modes beginning
        with <code>json-ld</code> as they are reserved for future versions
        of this specification.</dd>
      <dt><dfn data-dfn-for="jsonldoptions" data-dfn-type="dfn" id="dom-jsonldoptions-producegeneralizedrdf" data-idl="" data-title="produceGeneralizedRdf"><code>produceGeneralizedRdf</code></dfn></dt>
      <dd>If set to <code>true</code>, the JSON-LD processor may emit blank nodes for
        <a href="#dfn-triple" class="internalDFN" data-link-type="dfn">triple</a> <a data-link-type="dfn" href="https://www.w3.org/TR/rdf11-concepts/#dfn-predicate">predicates</a>, otherwise they will be omitted.</dd>
      </dl>
  </section> <!-- end JsonLdOptions -->

  <section id="remote-document-and-context-retrieval">
    <h3 id="x9-3-remote-document-and-context-retrieval"><span class="secno">9.3 </span>Remote Document and Context Retrieval&nbsp;<span class="permalink"><a href="#remote-document-and-context-retrieval" aria-label="Permalink for 9.3 Remote Document and Context Retrieval" title="Permalink for 9.3 Remote Document and Context Retrieval"><span>§</span></a></span></h3>

    <p>Users of an API implementation can utilize a callback to control how remote
      documents and contexts are retrieved. This section details the parameters of
      that callback and the data structure used to return the retrieved context.</p>

    <section id="loaddocumentcallback">
      <h4 id="x9-3-1-loaddocumentcallback"><span class="secno">9.3.1 </span>LoadDocumentCallback&nbsp;<span class="permalink"><a href="#loaddocumentcallback" aria-label="Permalink for 9.3.1 LoadDocumentCallback" title="Permalink for 9.3.1 LoadDocumentCallback"><span>§</span></a></span></h4>

      <p>The <dfn data-dfn-type="dfn" id="dom-loaddocumentcallback" data-idl="" data-title="LoadDocumentCallback" data-dfn-for=""><code>LoadDocumentCallback</code></dfn> defines a callback that custom document loaders
        have to implement to be used to retrieve remote documents and contexts.</p>

      <div><pre class="def idl"><span class="idlCallback" id="idl-def-loaddocumentcallback" data-idl="" data-title="LoadDocumentCallback">callback <span class="idlCallbackID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a></span> = <span class="idlCallbackType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>&gt;</span> (<span class="idlParam"><span class="idlParamType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlParamName">url</span></span>);</span></pre></div>

      <dl>
        <dt><dfn data-dfn-type="dfn" id="dfn-url">url</dfn></dt>
        <dd>The URL of the remote document or context to load.</dd>
      </dl>

      <p>All errors result in the <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> being rejected with
        a <a href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a> whose code is set to
        <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-loading-document-failed" class="internalDFN" data-link-type="dfn"><code>loading document failed</code></a>
        or <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-multiple-context-link-headers" class="internalDFN" data-link-type="dfn"><code>multiple context link headers</code></a>
        as described in the next section.</p>
    </section>

    <section id="remotedocument">
      <h4 id="x9-3-2-remotedocument"><span class="secno">9.3.2 </span>RemoteDocument&nbsp;<span class="permalink"><a href="#remotedocument" aria-label="Permalink for 9.3.2 RemoteDocument" title="Permalink for 9.3.2 RemoteDocument"><span>§</span></a></span></h4>

      <p>The <dfn data-dfn-type="dfn" id="dom-remotedocument" data-idl="" data-title="RemoteDocument" data-dfn-for=""><code>RemoteDocument</code></dfn> type is used by a <a href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a>
        to return information about a remote document or context.</p>

      <div><pre class="def idl"><span class="idlDictionary" id="idl-def-remotedocument" data-idl="" data-title="RemoteDocument">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-remotedocument" class="internalDFN" data-link-type="dfn"><code>RemoteDocument</code></a></span> {
<span class="idlMember" id="idl-def-remotedocument-contexturl" data-idl="" data-title="contextUrl" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-contexturl" class="internalDFN" data-link-type="dfn"><code>contextUrl</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" id="idl-def-remotedocument-documenturl" data-idl="" data-title="documentUrl" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-documenturl" class="internalDFN" data-link-type="dfn"><code>documentUrl</code></a></span>;</span>
<span class="idlMember" id="idl-def-remotedocument-document" data-idl="" data-title="document" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-any">any</a></span>       <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-document" class="internalDFN" data-link-type="dfn"><code>document</code></a></span>;</span>
};</span></pre></div>

      <dl>
        <dt><dfn data-dfn-for="remotedocument" data-dfn-type="dfn" id="dom-remotedocument-contexturl" data-idl="" data-title="contextUrl"><code>contextUrl</code></dfn></dt>
        <dd>If available, the value of the HTTP Link Header [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] using the
          <code>http://www.w3.org/ns/json-ld#context</code> link relation in the
          response. If the response's content type is <code>application/ld+json</code>,
          the HTTP Link Header is ignored. If multiple HTTP Link Headers using
          the <code>http://www.w3.org/ns/json-ld#context</code> link relation are found,
          the <a href="#dfn-promises" class="internalDFN" data-link-type="dfn">Promise</a> of the <a href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a> is rejected with
          a <a href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a> whose code is set to
          <a data-link-for="JsonLdErrorCode" href="#dom-jsonlderrorcode-multiple-context-link-headers" class="internalDFN" data-link-type="dfn"><code>multiple context link headers</code></a>.</dd>
        <dt><dfn data-dfn-for="remotedocument" data-dfn-type="dfn" id="dom-remotedocument-documenturl" data-idl="" data-title="documentUrl"><code>documentUrl</code></dfn></dt>
        <dd>The final URL of the loaded document. This is important
          to handle HTTP redirects properly.</dd>
        <dt><dfn data-dfn-for="remotedocument" data-dfn-type="dfn" id="dom-remotedocument-document" data-idl="" data-title="document"><code>document</code></dfn></dt>
        <dd>The retrieved document. This can either be the raw payload or the already
          parsed document.</dd>
      </dl>
    </section>
  </section> <!-- end of Remote Document and Context Retrieval -->

  <section id="error-handling">
    <h3 id="x9-4-error-handling"><span class="secno">9.4 </span>Error Handling&nbsp;<span class="permalink"><a href="#error-handling" aria-label="Permalink for 9.4 Error Handling" title="Permalink for 9.4 Error Handling"><span>§</span></a></span></h3>

    <p>This section describes the datatype definitions used within the
      JSON-LD API for error handling.</p>

    <section id="jsonlderror">
      <h4 id="x9-4-1-jsonlderror"><span class="secno">9.4.1 </span>JsonLdError&nbsp;<span class="permalink"><a href="#jsonlderror" aria-label="Permalink for 9.4.1 JsonLdError" title="Permalink for 9.4.1 JsonLdError"><span>§</span></a></span></h4>

      <p>The <dfn data-dfn-type="dfn" id="dom-jsonlderror" data-idl="" data-title="JsonLdError" data-dfn-for=""><code>JsonLdError</code></dfn> type is used to report processing errors.</p>

      <div><pre class="def idl"><span class="idlDictionary" id="idl-def-jsonlderror" data-idl="" data-title="JsonLdError">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a></span> {
<span class="idlMember" id="idl-def-jsonlderror-code" data-idl="" data-title="code" data-dfn-for="jsonlderror">    <span class="idlMemberType"><a href="#dom-jsonlderrorcode" class="internalDFN" data-link-type="dfn"><code>JsonLdErrorCode</code></a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="jsonlderror" data-lt="" href="#dom-jsonlderror-code" class="internalDFN" data-link-type="dfn"><code>code</code></a></span>;</span>
<span class="idlMember" id="idl-def-jsonlderror-message" data-idl="" data-title="message" data-dfn-for="jsonlderror">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>?</span>      <span class="idlMemberName"><a data-no-default="" data-link-for="jsonlderror" data-lt="" href="#dom-jsonlderror-message" class="internalDFN" data-link-type="dfn"><code>message</code></a></span> = <span class="idlMemberValue">null</span>;</span>
};</span></pre></div>

      <dl>
        <dt><dfn data-dfn-for="jsonlderror" data-dfn-type="dfn" id="dom-jsonlderror-code" data-idl="" data-title="code"><code>code</code></dfn></dt>
        <dd>a string representing the particular error type, as described in
          the various algorithms in this document.</dd>
        <dt><dfn data-dfn-for="jsonlderror" data-dfn-type="dfn" id="dom-jsonlderror-message" data-idl="" data-title="message"><code>message</code></dfn></dt>
        <dd>an optional error message containing additional debugging information.
          The specific contents of error messages are outside the scope of this
          specification.</dd>
      </dl>
    </section>

    <section id="jsonlderrorcode">
      <h4 id="x9-4-2-jsonlderrorcode"><span class="secno">9.4.2 </span>JsonLdErrorCode&nbsp;<span class="permalink"><a href="#jsonlderrorcode" aria-label="Permalink for 9.4.2 JsonLdErrorCode" title="Permalink for 9.4.2 JsonLdErrorCode"><span>§</span></a></span></h4>
      <p>The <dfn data-dfn-type="dfn" id="dom-jsonlderrorcode" data-idl="" data-title="JsonLdErrorCode" data-dfn-for=""><code>JsonLdErrorCode</code></dfn> represents the collection of valid JSON-LD error
        codes.</p>

      <div><pre class="def idl"><span class="idlEnum" id="idl-def-jsonlderrorcode" data-idl="" data-title="JsonLdErrorCode">enum <span class="idlEnumID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlderrorcode" class="internalDFN" data-link-type="dfn"><code>JsonLdErrorCode</code></a></span> {
    <a href="#dom-jsonlderrorcode-colliding-keywords" class="idlEnumItem">"colliding keywords"</a>,
    <a href="#dom-jsonlderrorcode-compaction-to-list-of-lists" class="idlEnumItem">"compaction to list of lists"</a>,
    <a href="#dom-jsonlderrorcode-conflicting-indexes" class="idlEnumItem">"conflicting indexes"</a>,
    <a href="#dom-jsonlderrorcode-cyclic-iri-mapping" class="idlEnumItem">"cyclic IRI mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid--id-value" class="idlEnumItem">"invalid @id value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--index-value" class="idlEnumItem">"invalid @index value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--nest-value" class="idlEnumItem">"invalid @nest value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--prefix-value" class="idlEnumItem">"invalid @prefix value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--reverse-value" class="idlEnumItem">"invalid @reverse value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--version-value" class="idlEnumItem">"invalid @version value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-base-iri" class="idlEnumItem">"invalid base IRI"</a>,
    <a href="#dom-jsonlderrorcode-invalid-container-mapping" class="idlEnumItem">"invalid container mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-default-language" class="idlEnumItem">"invalid default language"</a>,
    <a href="#dom-jsonlderrorcode-invalid-iri-mapping" class="idlEnumItem">"invalid IRI mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-keyword-alias" class="idlEnumItem">"invalid keyword alias"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-map-value" class="idlEnumItem">"invalid language map value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-mapping" class="idlEnumItem">"invalid language mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-tagged-string" class="idlEnumItem">"invalid language-tagged string"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-tagged-value" class="idlEnumItem">"invalid language-tagged value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-local-context" class="idlEnumItem">"invalid local context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-remote-context" class="idlEnumItem">"invalid remote context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property" class="idlEnumItem">"invalid reverse property"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property-map" class="idlEnumItem">"invalid reverse property map"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property-value" class="idlEnumItem">"invalid reverse property value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-scoped-context" class="idlEnumItem">"invalid scoped context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-set-or-list-object" class="idlEnumItem">"invalid set or list object"</a>,
    <a href="#dom-jsonlderrorcode-invalid-term-definition" class="idlEnumItem">"invalid term definition"</a>,
    <a href="#dom-jsonlderrorcode-invalid-type-mapping" class="idlEnumItem">"invalid type mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-type-value" class="idlEnumItem">"invalid type value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-typed-value" class="idlEnumItem">"invalid typed value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-value-object" class="idlEnumItem">"invalid value object"</a>,
    <a href="#dom-jsonlderrorcode-invalid-value-object-value" class="idlEnumItem">"invalid value object value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-vocab-mapping" class="idlEnumItem">"invalid vocab mapping"</a>,
    <a href="#dom-jsonlderrorcode-keyword-redefinition" class="idlEnumItem">"keyword redefinition"</a>,
    <a href="#dom-jsonlderrorcode-list-of-lists" class="idlEnumItem">"list of lists"</a>,
    <a href="#dom-jsonlderrorcode-loading-document-failed" class="idlEnumItem">"loading document failed"</a>,
    <a href="#dom-jsonlderrorcode-loading-remote-context-failed" class="idlEnumItem">"loading remote context failed"</a>,
    <a href="#dom-jsonlderrorcode-multiple-context-link-headers" class="idlEnumItem">"multiple context link headers"</a>,
    <a href="#dom-jsonlderrorcode-processing-mode-conflict" class="idlEnumItem">"processing mode conflict"</a>,
    <a href="#dom-jsonlderrorcode-recursive-context-inclusion" class="idlEnumItem">"recursive context inclusion"</a>
};</span></pre></div>

      <dl data-dfn-for="JsonLdErrorCode" data-sort=""><dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-colliding-keywords" data-idl="" data-title="colliding keywords"><code>colliding keywords</code></dfn></dt>
        <dd>Two properties which expand to the same keyword have been detected.
          This might occur if a <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> and an alias thereof
          are used at the same time.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-compaction-to-list-of-lists" data-idl="" data-title="compaction to list of lists"><code>compaction to list of lists</code></dfn></dt>
        <dd>The compacted document contains a list of lists as multiple
          lists have been compacted to the same term.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-conflicting-indexes" data-idl="" data-title="conflicting indexes"><code>conflicting indexes</code></dfn></dt>
        <dd>Multiple conflicting indexes have been found for the same node.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-cyclic-iri-mapping" data-idl="" data-title="cyclic IRI mapping"><code>cyclic <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></dfn></dt>
        <dd>A cycle in <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mappings</a> has been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--id-value" data-idl="" data-title="invalid @id value"><code>invalid @id value</code></dfn></dt>
        <dd>An <code>@id</code> member was encountered whose value was not a
          <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--index-value" data-idl="" data-title="invalid @index value"><code>invalid @index value</code></dfn></dt>
        <dd>An <code>@index</code> member was encountered whose value was
          not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>.</dd>
        <dt class="changed"><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--nest-value" data-idl="" data-title="invalid @nest value"><code>invalid @nest value</code></dfn></dt>
        <dd class="changed">An invalid value for <code>@nest</code> has been found.</dd>
        <dt class="changed"><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--prefix-value" data-idl="" data-title="invalid @prefix value"><code>invalid @prefix value</code></dfn></dt>
        <dd class="changed">An invalid value for <code>@prefix</code> has been found.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--reverse-value" data-idl="" data-title="invalid @reverse value"><code>invalid @reverse value</code></dfn></dt>
        <dd>An invalid value for an <code>@reverse</code> member has been detected,
          i.e., the value was not a <a class="changed" data-link-type="dfn" href="https://heycam.github.io/webidl/#dfn-dictionary">dictionary</a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid--version-value" data-idl="" data-title="invalid @version value"><code>invalid @version value</code></dfn></dt>
        <dd>The <code>@version</code> key was used in a <a href="#dfn-contexts" class="internalDFN" data-link-type="dfn">context</a> with
          an out of range value.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-base-iri" data-idl="" data-title="invalid base IRI"><code>invalid base <abbr title="Internationalized Resource Identifier">IRI</abbr></code></dfn></dt>
        <dd>An invalid <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> has been detected, i.e., it is
          neither an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> nor <code>null</code>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-container-mapping" data-idl="" data-title="invalid container mapping"><code>invalid container mapping</code></dfn></dt>
        <dd>An <code>@container</code> member was encountered whose value was
          not one of the following <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>:
          <code>@list</code>, <code>@set</code>, or <code>@index</code>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-default-language" data-idl="" data-title="invalid default language"><code>invalid default language</code></dfn></dt>
        <dd>The value of the <a href="#dfn-default-language" class="internalDFN" data-link-type="dfn">default language</a> is not a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a>
          or <code>null</code> and thus invalid.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-iri-mapping" data-idl="" data-title="invalid IRI mapping"><code>invalid <abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</code></dfn></dt>
        <dd>A <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> contains a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a> that has
          an invalid or missing <a href="#dfn-iri-mappings" class="internalDFN" data-link-type="dfn"><abbr title="Internationalized Resource Identifier">IRI</abbr> mapping</a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-keyword-alias" data-idl="" data-title="invalid keyword alias"><code>invalid keyword alias</code></dfn></dt>
        <dd>An invalid <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> alias definition has been
          encountered.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-language-map-value" data-idl="" data-title="invalid language map value"><code>invalid language map value</code></dfn></dt>
        <dd>An invalid value in a <a href="#dfn-language-maps" class="internalDFN" data-link-type="dfn">language map</a>
          has been detected. It has to be a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> or an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> of
          <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-language-mapping" data-idl="" data-title="invalid language mapping"><code>invalid language mapping</code></dfn></dt>
        <dd>An <code>@language</code> member in a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
          was encountered whose value was neither a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> nor
          <code>null</code> and thus invalid.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-language-tagged-string" data-idl="" data-title="invalid language-tagged string"><code>invalid language-tagged string</code></dfn></dt>
        <dd>A <a href="#dfn-language-tagged-strings" class="internalDFN" data-link-type="dfn">language-tagged string</a> with an invalid language
          value was detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-language-tagged-value" data-idl="" data-title="invalid language-tagged value"><code>invalid language-tagged value</code></dfn></dt>
        <dd>A <a href="#dfn-numbers" class="internalDFN" data-link-type="dfn">number</a>, <code>true</code>, or <code>false</code> with an
          associated <a href="#dfn-language-tag" class="internalDFN" data-link-type="dfn">language tag</a> was detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-local-context" data-idl="" data-title="invalid local context"><code>invalid local context</code></dfn></dt>
        <dd>In invalid <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> was detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-remote-context" data-idl="" data-title="invalid remote context"><code>invalid remote context</code></dfn></dt>
        <dd>No valid context document has been found for a referenced,
         remote context.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-reverse-property" data-idl="" data-title="invalid reverse property"><code>invalid reverse property</code></dfn></dt>
        <dd>An invalid reverse property definition has been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-reverse-property-map" data-idl="" data-title="invalid reverse property map"><code>invalid reverse property map</code></dfn></dt>
        <dd>An invalid reverse property map has been detected. No
          <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keywords</a> apart from <code>@context</code>
          are allowed in reverse property maps.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-reverse-property-value" data-idl="" data-title="invalid reverse property value"><code>invalid reverse property value</code></dfn></dt>
        <dd>An invalid value for a reverse property has been detected. The value of an inverse
          property must be a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>.</dd>
        <dt class="changed"><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-scoped-context" data-idl="" data-title="invalid scoped context"><code>invalid scoped context</code></dfn></dt>
        <dd class="changed">The <a href="#dfn-local-contexts" class="internalDFN" data-link-type="dfn">local context</a> defined within a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> is invalid.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-set-or-list-object" data-idl="" data-title="invalid set or list object"><code>invalid set or list object</code></dfn></dt>
        <dd>A <a href="#dfn-set-object" class="internalDFN" data-link-type="dfn">set object</a> or <a href="#dfn-list-objects" class="internalDFN" data-link-type="dfn">list object</a> with
          disallowed members has been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-term-definition" data-idl="" data-title="invalid term definition"><code>invalid term definition</code></dfn></dt>
        <dd>An invalid <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a> has been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-type-mapping" data-idl="" data-title="invalid type mapping"><code>invalid type mapping</code></dfn></dt>
        <dd>An <code>@type</code> member in a <a href="#dfn-term-definitions" class="internalDFN" data-link-type="dfn">term definition</a>
          was encountered whose value could not be expanded to an
          <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-type-value" data-idl="" data-title="invalid type value"><code>invalid type value</code></dfn></dt>
        <dd>An invalid value for an <code>@type</code> member has been detected,
          i.e., the value was neither a <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> nor an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a>
          of <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">strings</a>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-typed-value" data-idl="" data-title="invalid typed value"><code>invalid typed value</code></dfn></dt>
        <dd>A <a href="#dfn-typed-values" class="internalDFN" data-link-type="dfn">typed value</a> with an invalid type was detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-value-object" data-idl="" data-title="invalid value object"><code>invalid value object</code></dfn></dt>
        <dd>A <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> with disallowed members has been
          detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-value-object-value" data-idl="" data-title="invalid value object value"><code>invalid value object value</code></dfn></dt>
        <dd>An invalid value for the <code>@value</code> member of a
          <a href="#dfn-value-objects" class="internalDFN" data-link-type="dfn">value object</a> has been detected, i.e., it is neither
          a <a href="#dfn-scalar" class="internalDFN" data-link-type="dfn">scalar</a> nor <code>null</code>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-invalid-vocab-mapping" data-idl="" data-title="invalid vocab mapping"><code>invalid vocab mapping</code></dfn></dt>
        <dd>An invalid <a href="#dfn-vocabulary-mapping" class="internalDFN" data-link-type="dfn">vocabulary mapping</a> has been detected, i.e.,
          it is neither an <a href="#dfn-absolute-iris" class="internalDFN" data-link-type="dfn">absolute <abbr title="Internationalized Resource Identifier">IRI</abbr></a> nor <code>null</code>.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-keyword-redefinition" data-idl="" data-title="keyword redefinition"><code>keyword redefinition</code></dfn></dt>
        <dd>A <a href="#dfn-keywords" class="internalDFN" data-link-type="dfn">keyword</a> redefinition has been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-list-of-lists" data-idl="" data-title="list of lists"><code>list of lists</code></dfn></dt>
        <dd>A list of lists was detected. List of lists are not supported in
          this version of JSON-LD due to the algorithmic complexity.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-loading-document-failed" data-idl="" data-title="loading document failed"><code>loading document failed</code></dfn></dt>
        <dd>The document could not be loaded or parsed as JSON.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-loading-remote-context-failed" data-idl="" data-title="loading remote context failed"><code>loading remote context failed</code></dfn></dt>
        <dd>There was a problem encountered loading a remote context.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-multiple-context-link-headers" data-idl="" data-title="multiple context link headers"><code>multiple context link headers</code></dfn></dt>
        <dd>Multiple HTTP Link Headers [<cite><a class="bibref" href="#bib-RFC5988">RFC5988</a></cite>] using the
          <code>http://www.w3.org/ns/json-ld#context</code> link relation
          have been detected.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-processing-mode-conflict" data-idl="" data-title="processing mode conflict"><code>processing mode conflict</code></dfn></dt>
        <dd>An attempt was made to change the <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a> which is
          incompatible with the previous specified version.</dd>
        <dt><dfn data-dfn-for="jsonlderrorcode" data-dfn-type="dfn" id="dom-jsonlderrorcode-recursive-context-inclusion" data-idl="" data-title="recursive context inclusion"><code>recursive context inclusion</code></dfn></dt>
        <dd>A cycle in remote context inclusions has been detected.</dd></dl>
    </section>
  </section> <!-- end of Error Handling -->
</section> <!-- end of The Application Programming Interfaces -->

<section id="idl-index" class="appendix informative"><!--OddPage--><h2 id="a-idl-index"><span class="secno">A. </span>IDL Index&nbsp;<span class="permalink"><a href="#idl-index" aria-label="Permalink for A. IDL Index" title="Permalink for A. IDL Index"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>
<div><pre class="idl def" id="actual-idl-index"><span class="respec-idl-separator"><span class="idlInterface" data-idl="" data-title="JsonLdProcessor">[<span class="idlCtor"><span class="extAttrName"><a href="https://heycam.github.io/webidl/#Constructor">Constructor</a></span></span>]
interface <span class="idlInterfaceID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldprocessor" class="internalDFN" data-link-type="dfn"><code>JsonLdProcessor</code></a></span> {
<span class="idlMethod" data-idl="" data-title="compact" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;</span>           <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="compact|compact()" href="#dom-jsonldprocessor-compact" class="internalDFN" data-link-type="dfn"><code>compact</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                       <span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a></span> <span class="idlParamName">context</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod" data-idl="" data-title="expand" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;&gt;</span> <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="expand|expand()" href="#dom-jsonldprocessor-expand" class="internalDFN" data-link-type="dfn"><code>expand</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                      <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
<span class="idlMethod" data-idl="" data-title="flatten" data-dfn-for="jsonldprocessor">    static <span class="idlMethType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt;</span>           <span class="idlMethName"><a data-no-default="" data-link-for="jsonldprocessor" data-lt="flatten|flatten()" href="#dom-jsonldprocessor-flatten" class="internalDFN" data-link-type="dfn"><code>flatten</code></a></span>(<span class="idlParam"><span class="idlParamType"><a href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span> <span class="idlParamName">input</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a>?</span> <span class="idlParamName">context</span></span>,
                                                       <span class="idlParam">optional <span class="idlParamType"><a href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a>?</span> <span class="idlParamName">options</span></span>);</span>
};</span>
</span><span class="respec-idl-separator"><span class="idlDictionary" data-idl="" data-title="JsonLdDictionary">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a></span> {
};</span>
</span><span class="respec-idl-separator"><span class="idlTypedef" data-idl="" data-title="JsonLdInput">typedef <span class="idlTypedefType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>&gt; or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)</span> <span class="idlTypedefID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldinput" class="internalDFN" data-link-type="dfn"><code>JsonLdInput</code></a></span>;</span>
</span><span class="respec-idl-separator"><span class="idlTypedef" data-idl="" data-title="JsonLdContext">typedef <span class="idlTypedefType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a> or <a href="https://heycam.github.io/webidl/#idl-sequence">sequence</a>&lt;(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a> or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)&gt;)</span> <span class="idlTypedefID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldcontext" class="internalDFN" data-link-type="dfn"><code>JsonLdContext</code></a></span>;</span>
</span><span class="respec-idl-separator"><span class="idlDictionary" data-idl="" data-title="JsonLdOptions">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonldoptions" class="internalDFN" data-link-type="dfn"><code>JsonLdOptions</code></a></span> {
<span class="idlMember" data-idl="" data-title="base" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>?</span>                       <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-base" class="internalDFN" data-link-type="dfn"><code>base</code></a></span>;</span>
<span class="idlMember" data-idl="" data-title="compactArrays" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-compactarrays" class="internalDFN" data-link-type="dfn"><code>compactArrays</code></a></span> = <span class="idlMemberValue">true</span>;</span>
<span class="idlMember" data-idl="" data-title="compactToRelative" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a></span> = <span class="idlMemberValue">true</span>;</span>
<span class="idlMember" data-idl="" data-title="documentLoader" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a></span>             <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-documentloader" class="internalDFN" data-link-type="dfn"><code>documentLoader</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" data-idl="" data-title="expandContext" data-dfn-for="jsonldoptions">    <span class="idlMemberType">(<a href="#dom-jsonlddictionary" class="internalDFN" data-link-type="dfn"><code>JsonLdDictionary</code></a>? or <a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>)</span> <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-expandcontext" class="internalDFN" data-link-type="dfn"><code>expandContext</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" data-idl="" data-title="frameExpansion" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-frameexpansion" class="internalDFN" data-link-type="dfn"><code>frameExpansion</code></a></span> = <span class="idlMemberValue">false</span>;</span>
<span class="idlMember" data-idl="" data-title="processingMode" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span>                        <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-processingmode" class="internalDFN" data-link-type="dfn"><code>processingMode</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" data-idl="" data-title="produceGeneralizedRdf" data-dfn-for="jsonldoptions">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-boolean">boolean</a></span>                          <span class="idlMemberName"><a data-no-default="" data-link-for="jsonldoptions" data-lt="" href="#dom-jsonldoptions-producegeneralizedrdf" class="internalDFN" data-link-type="dfn"><code>produceGeneralizedRdf</code></a></span> = <span class="idlMemberValue">true</span>;</span>
};</span>
</span><span class="respec-idl-separator"><span class="idlCallback" data-idl="" data-title="LoadDocumentCallback">callback <span class="idlCallbackID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-loaddocumentcallback" class="internalDFN" data-link-type="dfn"><code>LoadDocumentCallback</code></a></span> = <span class="idlCallbackType"><a href="https://heycam.github.io/webidl/#idl-promise">Promise</a>&lt;<a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>&gt;</span> (<span class="idlParam"><span class="idlParamType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlParamName">url</span></span>);</span>
</span><span class="respec-idl-separator"><span class="idlDictionary" data-idl="" data-title="RemoteDocument">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-remotedocument" class="internalDFN" data-link-type="dfn"><code>RemoteDocument</code></a></span> {
<span class="idlMember" data-idl="" data-title="contextUrl" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-contexturl" class="internalDFN" data-link-type="dfn"><code>contextUrl</code></a></span> = <span class="idlMemberValue">null</span>;</span>
<span class="idlMember" data-idl="" data-title="documentUrl" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-documenturl" class="internalDFN" data-link-type="dfn"><code>documentUrl</code></a></span>;</span>
<span class="idlMember" data-idl="" data-title="document" data-dfn-for="remotedocument">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-any">any</a></span>       <span class="idlMemberName"><a data-no-default="" data-link-for="remotedocument" data-lt="" href="#dom-remotedocument-document" class="internalDFN" data-link-type="dfn"><code>document</code></a></span>;</span>
};</span>
</span><span class="respec-idl-separator"><span class="idlDictionary" data-idl="" data-title="JsonLdError">dictionary <span class="idlDictionaryID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlderror" class="internalDFN" data-link-type="dfn"><code>JsonLdError</code></a></span> {
<span class="idlMember" data-idl="" data-title="code" data-dfn-for="jsonlderror">    <span class="idlMemberType"><a href="#dom-jsonlderrorcode" class="internalDFN" data-link-type="dfn"><code>JsonLdErrorCode</code></a></span> <span class="idlMemberName"><a data-no-default="" data-link-for="jsonlderror" data-lt="" href="#dom-jsonlderror-code" class="internalDFN" data-link-type="dfn"><code>code</code></a></span>;</span>
<span class="idlMember" data-idl="" data-title="message" data-dfn-for="jsonlderror">    <span class="idlMemberType"><a href="https://heycam.github.io/webidl/#idl-USVString">USVString</a>?</span>      <span class="idlMemberName"><a data-no-default="" data-link-for="jsonlderror" data-lt="" href="#dom-jsonlderror-message" class="internalDFN" data-link-type="dfn"><code>message</code></a></span> = <span class="idlMemberValue">null</span>;</span>
};</span>
</span><span class="respec-idl-separator"><span class="idlEnum" data-idl="" data-title="JsonLdErrorCode">enum <span class="idlEnumID"><a data-no-default="" data-link-for="" data-lt="" href="#dom-jsonlderrorcode" class="internalDFN" data-link-type="dfn"><code>JsonLdErrorCode</code></a></span> {
    <a href="#dom-jsonlderrorcode-colliding-keywords" class="idlEnumItem">"colliding keywords"</a>,
    <a href="#dom-jsonlderrorcode-compaction-to-list-of-lists" class="idlEnumItem">"compaction to list of lists"</a>,
    <a href="#dom-jsonlderrorcode-conflicting-indexes" class="idlEnumItem">"conflicting indexes"</a>,
    <a href="#dom-jsonlderrorcode-cyclic-iri-mapping" class="idlEnumItem">"cyclic IRI mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid--id-value" class="idlEnumItem">"invalid @id value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--index-value" class="idlEnumItem">"invalid @index value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--nest-value" class="idlEnumItem">"invalid @nest value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--prefix-value" class="idlEnumItem">"invalid @prefix value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--reverse-value" class="idlEnumItem">"invalid @reverse value"</a>,
    <a href="#dom-jsonlderrorcode-invalid--version-value" class="idlEnumItem">"invalid @version value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-base-iri" class="idlEnumItem">"invalid base IRI"</a>,
    <a href="#dom-jsonlderrorcode-invalid-container-mapping" class="idlEnumItem">"invalid container mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-default-language" class="idlEnumItem">"invalid default language"</a>,
    <a href="#dom-jsonlderrorcode-invalid-iri-mapping" class="idlEnumItem">"invalid IRI mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-keyword-alias" class="idlEnumItem">"invalid keyword alias"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-map-value" class="idlEnumItem">"invalid language map value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-mapping" class="idlEnumItem">"invalid language mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-tagged-string" class="idlEnumItem">"invalid language-tagged string"</a>,
    <a href="#dom-jsonlderrorcode-invalid-language-tagged-value" class="idlEnumItem">"invalid language-tagged value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-local-context" class="idlEnumItem">"invalid local context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-remote-context" class="idlEnumItem">"invalid remote context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property" class="idlEnumItem">"invalid reverse property"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property-map" class="idlEnumItem">"invalid reverse property map"</a>,
    <a href="#dom-jsonlderrorcode-invalid-reverse-property-value" class="idlEnumItem">"invalid reverse property value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-scoped-context" class="idlEnumItem">"invalid scoped context"</a>,
    <a href="#dom-jsonlderrorcode-invalid-set-or-list-object" class="idlEnumItem">"invalid set or list object"</a>,
    <a href="#dom-jsonlderrorcode-invalid-term-definition" class="idlEnumItem">"invalid term definition"</a>,
    <a href="#dom-jsonlderrorcode-invalid-type-mapping" class="idlEnumItem">"invalid type mapping"</a>,
    <a href="#dom-jsonlderrorcode-invalid-type-value" class="idlEnumItem">"invalid type value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-typed-value" class="idlEnumItem">"invalid typed value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-value-object" class="idlEnumItem">"invalid value object"</a>,
    <a href="#dom-jsonlderrorcode-invalid-value-object-value" class="idlEnumItem">"invalid value object value"</a>,
    <a href="#dom-jsonlderrorcode-invalid-vocab-mapping" class="idlEnumItem">"invalid vocab mapping"</a>,
    <a href="#dom-jsonlderrorcode-keyword-redefinition" class="idlEnumItem">"keyword redefinition"</a>,
    <a href="#dom-jsonlderrorcode-list-of-lists" class="idlEnumItem">"list of lists"</a>,
    <a href="#dom-jsonlderrorcode-loading-document-failed" class="idlEnumItem">"loading document failed"</a>,
    <a href="#dom-jsonlderrorcode-loading-remote-context-failed" class="idlEnumItem">"loading remote context failed"</a>,
    <a href="#dom-jsonlderrorcode-multiple-context-link-headers" class="idlEnumItem">"multiple context link headers"</a>,
    <a href="#dom-jsonlderrorcode-processing-mode-conflict" class="idlEnumItem">"processing mode conflict"</a>,
    <a href="#dom-jsonlderrorcode-recursive-context-inclusion" class="idlEnumItem">"recursive context inclusion"</a>
};</span>
</span></pre></div></section>

<section id="security" class="appendix">
  <!--OddPage--><h2 id="b-security-considerations"><span class="secno">B. </span>Security Considerations&nbsp;<span class="permalink"><a href="#security" aria-label="Permalink for B. Security Considerations" title="Permalink for B. Security Considerations"><span>§</span></a></span></h2>
  <div class="ednote" id="issue-container-generatedID-1"><div role="heading" class="ednote-title marker" id="h-ednote" aria-level="3"><span>Editor's note</span></div><p class="">Consider requirements from <a href="https://w3ctag.github.io/security-questionnaire/">Self-Review Questionnaire: Security and Privacy</a>.</p></div>
</section>

<section class="appendix informative" id="changes-since-1-0-recommendation-of-16-january-2014">
  <!--OddPage--><h2 id="c-changes-since-1-0-recommendation-of-16-january-2014"><span class="secno">C. </span>Changes since 1.0 Recommendation of 16 January 2014&nbsp;<span class="permalink"><a href="#changes-since-1-0-recommendation-of-16-january-2014" aria-label="Permalink for C. Changes since 1.0 Recommendation of 16 January 2014" title="Permalink for C. Changes since 1.0 Recommendation of 16 January 2014"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>
  <ul>
    <li>The <a href="#expansion-algorithm">Expansion Algorithm</a>
      has a special <a href="#dfn-processing-mode" class="internalDFN" data-link-type="dfn">processing mode</a>, based on
      the <var>frame expansion</var> flag, to enable content associated with JSON-LD
      frames, which may not otherwise be valid <a href="#dfn-json-ld-documents" class="internalDFN" data-link-type="dfn">JSON-LD documents</a>.</li>
    <li>An <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a> can now have an
      <code>@context</code> property, which defines a context used for values of
      a <a href="#dfn-properties" class="internalDFN" data-link-type="dfn">property</a> identified with such a <a href="#dfn-terms" class="internalDFN" data-link-type="dfn">term</a>. This context is used
      in both the <a href="#expansion-algorithm">Expansion Algorithm</a> and
      <a href="#compaction-algorithm">Compaction Algorithm</a>.</li>
    <li>A new <a href="#merge-node-maps" class="sectionRef sec-ref">section <span class="secno">7.4</span> <span class="sec-title">Merge Node Maps</span></a> is required
      for framing, to create a single graph from the <a data-lt="default graph" href="#dfn-default-graph" class="internalDFN" data-link-type="dfn">default</a>
      and <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graphs</a>.</li>
    <li>An <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a> can now have an
      <code>@nest</code> property, which identifies a term expanding to
      <code>@nest</code> which is used for containing properties using the same
      <code>@nest</code> mapping. When expanding, the values of a property
      expanding to <code>@nest</code> are treated as if they were contained
      within the enclosing <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a> directly.</li>
    <li><code>@container</code> values within an <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a> may now
      include <code>@id</code> and <code>@type</code>, corresponding to <a href="#dfn-id-maps" class="internalDFN" data-link-type="dfn">id maps</a> and <a href="#dfn-type-maps" class="internalDFN" data-link-type="dfn">type maps</a>.</li>
    <li>Both <a href="#dfn-language-maps" class="internalDFN" data-link-type="dfn">language maps</a> and <a href="#dfn-index-maps" class="internalDFN" data-link-type="dfn">index maps</a> may legitimately have an <code>@none</code> value, but
      JSON-LD 1.0 only allowed <a href="#dfn-strings" class="internalDFN" data-link-type="dfn">string</a> values. This has been updated
      to allow (and ignore) <code>@none</code> values.</li>
    <li>The JSON syntax has been abstracted into an <a href="#dfn-internal-representation" class="internalDFN" data-link-type="dfn">internal representation</a>
      to allow for other serialization formats that are functionally equivalent
      to JSON.</li>
    <li>Preserved values are compacted using the properties of the referencing term.</li>
    <li>The value for <code>@container</code> in an <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a>
      can also be an <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> containing any appropriate container
      keyword along with <code>@set</code> (other than <code>@list</code>).
      This allows a way to ensure that such property values will always
      be expressed in <a href="#dfn-arrays" class="internalDFN" data-link-type="dfn">array</a> form.</li>
    <li>Added support for the <a data-link-for="JsonLdOptions" href="#dom-jsonldoptions-compacttorelative" class="internalDFN" data-link-type="dfn"><code>compactToRelative</code></a> option to allow <abbr title="Internationalized Resource Identifier">IRI</abbr> compaction (<a href="#iri-compaction" class="sectionRef sec-ref">section <span class="secno">6.3</span> <span class="sec-title">IRI Compaction</span></a>)
      to document relative IRIs to be disabled.</li>
    <li>In JSON-LD 1.1, terms will be used as <a href="#dfn-compact-iris" class="internalDFN" data-link-type="dfn">compact <abbr title="Internationalized Resource Identifier">IRI</abbr></a> prefixes
      when compacting only if
      a <a href="#dfn-simple-terms" class="internalDFN" data-link-type="dfn">simple term definition</a> is used where the value ends with a URI <a href="https://tools.ietf.org/html/rfc3986#section-2.2">gen-delim</a> character,
      or if their <a href="#dfn-expanded-term-definitions" class="internalDFN" data-link-type="dfn">expanded term definition</a> contains
      a <code>@prefix</code> member with the value <a href="#dfn-true" class="internalDFN" data-link-type="dfn">true</a>. The 1.0 algorithm has
      been updated to only consider terms that map to a value that ends with a URI
      <a href="https://tools.ietf.org/html/rfc3986#section-2.2">gen-delim</a> character.</li>
    <li>Term definitions now allow <code>@container</code> to include <code>@graph</code>,
      along with <code>@id</code>, <code>@index</code> and <code>@set</code>.
      In the <a href="#expansion-algorithm">Expansion Algorithm</a>, this is
      used to create a <a href="#dfn-named-graphs" class="internalDFN" data-link-type="dfn">named graph</a> from either a <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node object</a>, or
      objects which are values of keys in an <a href="#dfn-id-maps" class="internalDFN" data-link-type="dfn">id map</a> or <a href="#dfn-index-maps" class="internalDFN" data-link-type="dfn">index map</a>.
      the <a href="#compaction-algorithm">Compaction Algorithm</a> allows
      specific forms of graph objects to be compacted back to a set of <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node
      objects</a>, or maps of <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a>.</li>
    <li><a href="#value-expansion">Value Expansion</a> will not turn native values
      into <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a>.</li>
    <li>The <a href="#term-selection">Term Selection algorithm</a> has been
      updated to allow uses of containers for values which would otherwise not
      match. This is used in the <a href="#expansion-algorithm">Compaction
      Algorithm</a> to use the <code>@none</code> keyword, or an alias, for
      values of maps for which there is no natural index. The <a href="#expansion-algorithm">Expansion Algorithm</a> removes this indexing
      transparently.</li>
    <li>The empty string (<code>""</code>) has been added as a possible value for <code>@vocab</code> in
      a context. When this is set, vocabulary-relative IRIs, such as the
      keys of <a href="#dfn-node-objects" class="internalDFN" data-link-type="dfn">node objects</a>, are expanded or compacted relative
      to the <a href="#dfn-base-iris" class="internalDFN" data-link-type="dfn">base <abbr title="Internationalized Resource Identifier">IRI</abbr></a> using string concatenation.</li>
  </ul>
</section>

<section class="appendix informative" id="open-issues">
  <!--OddPage--><h2 id="d-open-issues"><span class="secno">D. </span>Open Issues&nbsp;<span class="permalink"><a href="#open-issues" aria-label="Permalink for D. Open Issues" title="Permalink for D. Open Issues"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>
  <p>The following is a list of issues open at the time of publication.</p>
  <div class="issue" id="issue-container-number-246"><div role="heading" class="issue-title marker" id="h-issue" aria-level="3"><a href="https://github.com/json-ld/issues/246"><span>Issue 246</span></a><span style="text-transform: none">: Ignoring semantically meaningless nesting<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org/issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org/issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org/issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org/issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>Thanks for the great work with JSON-LD! However, when trying to use JSON-LD for to present data in the company I'm working in, I noticed the following missing feature:</p>
<p>FEATURE PROPOSAL: ABILITY TO DEFINE ANY KEY AS AN INDEX KEY</p>
<p>In addition to JSON-LD's existing index container structure, I propose that any key under a JSON-LD node could be defined as a index key.</p>
<p>This would help clustering data under a node into coder friendly logical groups without messing up the Linked Data interpretation with e.g. blank nodes. I encountered the need for this feature at our company where our problem is that the amount of attributes a single JSON-LD node can have can potentially be quite many, say, tens or hundreds of attributes.</p>
<p>As far as I know, this can not be currently done with JSON-LD without 1) ending up with blank nodes or  2) the need to create a deeper JSON structure by using a separate index term (using "<a class="user-mention" data-hovercard-user-id="107486" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/container">@container</a>":"<a class="user-mention" href="https://github.com/index">@index</a>") which then contains the data underneath.</p>
<p>In addition, if a single key could be defined as a index term, this would make it more flexible to attach the JSON-LD Linked Data interpretation to even a wider amount of existing JSON data, without having to change the structure of such data (and without ending up with e.g. lots of blank nodes).</p>
<p>DEFINING AN INDIVIDUAL INDEX KEY IN <a class="user-mention" data-hovercard-user-id="36477" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/context">@context</a></p>
<p>The "<a class="user-mention" data-hovercard-user-id="36477" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/context">@context</a>" definition could be done e.g. using the existing reserved keyword "<a class="user-mention" href="https://github.com/index">@index</a>" in the following way:</p>
<pre aria-busy="false" class="hljs css">"<span class="hljs-selector-tag">indexkey</span>"<span class="hljs-selector-pseudo">:"</span>@<span class="hljs-keyword">index</span>"
</pre>
<p>which should be interpreted in the following way: 1) the "indexkey" is an index key and should be skipped when traversing the JSON tree while doing the JSON-LD to RDF interpretation, 2) any data directly under the "indexkey" should be interpreted as data directly attached to the node of the indexkey (same RDF subject).</p>
<p>EXAMPLE</p>
<p>To give a full example, in the following a single key "labels" is defined as an index index key to help grouping the data into coder friendly logical groups without messing up the Linked Data interpretation):</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
     <span class="hljs-attr">"labels"</span>:<span class="hljs-string">"@index"</span>,
     <span class="hljs-attr">"main_label"</span>:<span class="hljs-string">"http://example.org/my-schema#main_label"</span>,
     <span class="hljs-attr">"other_label"</span>:<span class="hljs-string">"http://example.org/my-schema#other_label"</span>,
     <span class="hljs-attr">"homepage"</span>:{ <span class="hljs-attr">"@id"</span>:<span class="hljs-string">"http://example.org/my-schema#homepage"</span>, <span class="hljs-attr">"@type"</span>:<span class="hljs-string">"@id"</span>}
  },
  <span class="hljs-attr">"@id"</span>:<span class="hljs-string">"http://example.org/myresource"</span>,
  <span class="hljs-attr">"homepage"</span>: <span class="hljs-string">"http://example.org"</span>,
  <span class="hljs-attr">"labels"</span>: {
     <span class="hljs-attr">"main_label"</span>: <span class="hljs-string">"This is the main label for my resource"</span>,
     <span class="hljs-attr">"other_label"</span>: <span class="hljs-string">"This is the other label"</span>
  }
}</pre></div>
<p>This example JSON-LD should generate the following RDF triplets:</p>
<pre aria-busy="false" class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">myresource</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">my-schema</span>#<span class="hljs-attr">homepage</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>&gt;</span>.
<span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">myresource</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">my-schema</span>#<span class="hljs-attr">main_label</span>&gt;</span> "This is the main label for my resource".
<span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">myresource</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.org</span>/<span class="hljs-attr">my-schema</span>#<span class="hljs-attr">other_label</span>&gt;</span> "This is the other label".
</pre></div>
  <div class="issue" id="issue-container-number-333"><div role="heading" class="issue-title marker" id="h-issue-0" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/333"><span>Issue 333</span></a><span style="text-transform: none">: Support JSON values that aren't mapped<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>This has already been discussed several times usingvarious terms.. the most recent request has come from <a href="http://lists.w3.org/Archives/Public/public-linked-json/2014Mar/0010.html" rel="nofollow">David Janes on the mailing list</a>. The basic idea is to support JSON values/subtrees that aren't mapped to an IRI in the context. They should survive algorithmic transformations (basically without being touched at all).</p></div>
  <div class="issue" id="issue-container-number-338"><div role="heading" class="issue-title marker" id="h-issue-1" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/338"><span>Issue 338</span></a><span style="text-transform: none">: Option to compact terms but not values<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a></span></div><p><strong>_This was raised by <a href="http://lists.w3.org/Archives/Public/public-linked-json/2014Mar/0033.html" rel="nofollow">Fabian Steeg</a>:</strong>_</p>
<blockquote>
<p>The JSON-LD API document states: "Expansion has two important goals: removing any contextual information from the document, and ensuring all values are represented in a regular form."</p>
<p>Is there a way to achieve only the second goal, the regular form, but with compact terms? Using compaction with compactArrays=false is pretty close, but there is still at least one thing that is irregular and causing issues for me.</p>
<p>Given this input:</p>
<pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"http://example.com/foo"</span>: <span class="hljs-string">"foo-value"</span>,
  <span class="hljs-attr">"http://example.com/bar"</span>: {
    <span class="hljs-attr">"@value"</span>: <span class="hljs-string">"bar-value"</span>,
    <span class="hljs-attr">"@language"</span>: <span class="hljs-string">"en"</span>
  },
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"foo"</span>: <span class="hljs-string">"http://example.com/foo"</span>,
    <span class="hljs-attr">"bar"</span>: <span class="hljs-string">"http://example.com/bar"</span>
  }
}
</pre>
<p>I get this from compaction with compactArrays=false:</p>
<pre aria-busy="false" class="hljs javascript">{
  <span class="hljs-string">"@graph"</span>: [{
    <span class="hljs-string">"foo"</span>: [<span class="hljs-string">"foo-value"</span>],              &lt;-- foo: array <span class="hljs-keyword">of</span> strings
    <span class="hljs-string">"bar"</span>: [{                          &lt;-- bar: array <span class="hljs-keyword">of</span> objects
      <span class="hljs-string">"@language"</span>: <span class="hljs-string">"en"</span>,
      <span class="hljs-string">"@value"</span>: <span class="hljs-string">"bar-value"</span>
    }]
  }],
  <span class="hljs-string">"@context"</span>: {
    <span class="hljs-string">"foo"</span>: <span class="hljs-string">"http://example.com/foo"</span>,
    <span class="hljs-string">"bar"</span>: <span class="hljs-string">"http://example.com/bar"</span>
  }
}
</pre>
<p>But I'd like to get this (which is what expansion does to the values):</p>
<pre aria-busy="false" class="hljs javascript">{
  <span class="hljs-string">"@graph"</span>: [{
    <span class="hljs-string">"foo"</span>: [{                          &lt;-- both foo and bar:
      <span class="hljs-string">"@value"</span> : <span class="hljs-string">"foo-value"</span>               array <span class="hljs-keyword">of</span> objects
    }],
    <span class="hljs-string">"bar"</span>: [{
      <span class="hljs-string">"@language"</span>: <span class="hljs-string">"en"</span>,
      <span class="hljs-string">"@value"</span>: <span class="hljs-string">"bar-value"</span>
    }]
  }],
  <span class="hljs-string">"@context"</span>: {
    <span class="hljs-string">"foo"</span>: <span class="hljs-string">"http://example.com/foo"</span>,
    <span class="hljs-string">"bar"</span>: <span class="hljs-string">"http://example.com/bar"</span>
  }
}
</pre>
<p>So I guess I'm looking for something like a compactValues=false option.</p>
<p>Is there some way to get this output?</p>
</blockquote></div>
  <div class="issue" id="issue-container-number-357"><div role="heading" class="issue-title marker" id="h-issue-2" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/357"><span>Issue 357</span></a><span style="text-transform: none">: Lists shared between graphs are not correctly serialized<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-bug%22" style="background-color: rgb(215, 225, 2);">spec-bug</a></span></div><p><strong>_<a href="http://lists.w3.org/Archives/Public/public-rdf-comments/2014Jul/0011.html" rel="nofollow">Reported</a> by <a class="user-mention" data-hovercard-user-id="101362" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/afs">@afs</a>:</strong>_</p>
<p>We are encountering an issue when converting RDF Datasets to JSON-LD.</p>
<p>The problem is with blank nodes that are shared between graphs and lists.</p>
<p>In TriG (yes, this is a synthetic reduced test case that captures a<br>
smaller example that might appear for real):</p>
<pre aria-busy="false" class="hljs xml"># Bnode references across graph and lists
PREFIX :        <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.example.com</span>/&gt;</span>
PREFIX rdf:     <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#&gt;</span>

:G {
   # Written in short form it would be:
   # :z :q ("cell-A" "cell-B")
   # but we want to share the tail ("cell-B")

   :z :q _:z0 .

   _:z0   rdf:first "cell-A" .
   _:z0   rdf:rest  _:z1 .

   _:z1   rdf:first "cell-B" .
   _:z1   rdf:rest rdf:nil .
}

:G1 {
    # This references the tail  ("cell-B")
    :x :p _:z1 .
}
</pre>
<p>The triple in :G1 references into the list in :G.</p>
<p>But as we understand the conversion algorithm, section 4 only considers<br>
each graph in turn and so does not see the cross graph sharing.</p>
<p>Is this a correct reading of the spec text?</p>
<p>Part 4 of the conversion algorithm has<br>
"For each name and graph object in graph map: "</p>
<p>so 4.3.3.* walks back up the list in one graph only.</p>
<p>(Conversion generated by jsonld-java : it does not matter if compaction<br>
is applied or not):</p>
<pre aria-busy="false" class="hljs json">{
   <span class="hljs-attr">"@graph"</span> : [ {
     <span class="hljs-attr">"@graph"</span> : [ {
       <span class="hljs-attr">"@id"</span> : <span class="hljs-string">":z"</span>,
       <span class="hljs-attr">":q"</span> : {
         <span class="hljs-attr">"@list"</span> : [ <span class="hljs-string">"cell-A"</span>, <span class="hljs-string">"cell-B"</span> ]
       }
     } ],
     <span class="hljs-attr">"@id"</span> : <span class="hljs-string">":G"</span>
   }, {
     <span class="hljs-attr">"@graph"</span> : [ {
       <span class="hljs-attr">"@id"</span> : <span class="hljs-string">":x"</span>,
       <span class="hljs-attr">":p"</span> : {
         <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"_:b1"</span>
       }
     } ],
     <span class="hljs-attr">"@id"</span> : <span class="hljs-string">":G1"</span>
   } ],
   <span class="hljs-attr">"@context"</span> : {
     <span class="hljs-attr">"@base"</span> : <span class="hljs-string">"http://www.example.com/"</span>,
     <span class="hljs-attr">""</span> : <span class="hljs-string">"http://www.example.com/"</span>,
     <span class="hljs-attr">"rdf"</span> : <span class="hljs-string">"http://www.w3.org/1999/02/22-rdf-syntax-ns#"</span>
   }
}
</pre>
<p>There is no _:b1 in :G to refer to because the algorith generated <a class="user-mention" data-hovercard-user-id="1133421" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/list">@list</a><br>
and its implicit bNodes don't have labels.<br>
This is a different dataset with no shared bNode.</p>
<p>If it is all the same graph (s/:G1/:G/), the RDF dataset structure is<br>
correctly serialized.</p>
<p>Andy</p></div>
  <div class="issue" id="issue-container-number-368"><div role="heading" class="issue-title marker" id="h-issue-3" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/368"><span>Issue 368</span></a><span style="text-transform: none">: JSON-LD 1.1 Feature Request: Object-level @language<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>See: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="44733813" data-permission-text="Issue title is private" data-url="https://github.com/digitalbazaar/jsonld.js/issues/72" href="https://github.com/digitalbazaar/jsonld.js/issues/72">digitalbazaar/jsonld.js#72</a></p>
<p>It would be helpful to have the ability to use <a class="user-mention" href="https://github.com/language">@language</a> within an object as a shorthand for "<a class="user-mention" data-hovercard-user-id="36477" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/context">@context</a>": {"<a class="user-mention" href="https://github.com/language">@language</a>": "..."} ... for instance... make:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@language"</span>: <span class="hljs-string">"en"</span>,
  <span class="hljs-attr">"displayName"</span>: <span class="hljs-string">"foo"</span>
}</pre></div>
<p>equivalent to:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {<span class="hljs-attr">"@language"</span>: <span class="hljs-string">"en"</span>},
  <span class="hljs-attr">"displayName"</span>: <span class="hljs-string">"foo"</span>
}</pre></div></div>
  <div class="issue" id="issue-container-number-371"><div role="heading" class="issue-title marker" id="h-issue-4" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/371"><span>Issue 371</span></a><span style="text-transform: none">: JSON-LD 1.1 Feature Request: New @label keyword<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>In the spirit of "Labeling Everything" (<a href="http://patterns.dataincubator.org/book/label-everything.html" rel="nofollow">http://patterns.dataincubator.org/book/label-everything.html</a>) ... it would be worthwhile, IMO, for JSON-LD to provide a basic <a class="user-mention" data-hovercard-user-id="2590355" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/Label">@Label</a> keyword for use both in <a class="user-mention" data-hovercard-user-id="36477" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/context">@context</a> and nodes. It's largely syntactic sugar but would be useful.</p>
<p>For example:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"@label"</span>: <span class="hljs-string">"An Example Context"</span>,
    <span class="hljs-attr">"displayName"</span>: <span class="hljs-string">"@label"</span>,
  },
  <span class="hljs-attr">"displayName"</span>: <span class="hljs-string">"A Simple Label"</span>
}</pre></div>
<p>Which would expand to:</p>
<pre aria-busy="false" class="hljs javascript">_:c14n0 &lt;http:<span class="hljs-comment">//www.w3.org/2000/01/rdf-schema#label&gt; "A Simple Label" .</span>
</pre></div>
  <div class="issue" id="issue-container-number-397"><div role="heading" class="issue-title marker" id="h-issue-5" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/397"><span>Issue 397</span></a><span style="text-transform: none">: JSON-LD 1.1 Feature Request: support @values for describing multidimensional containers (list of lists)<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><h2 id="problem-description">Problem description&nbsp;<span class="permalink"><a href="#issue-container-number-397" aria-label="Permalink for Problem description" title="Permalink for Problem description"><span>§</span></a></span></h2>
<p>Many JSON specs existed before JSON-LD. A couple of these specs may not be compatible with JSON-LD as they contain multidimensional containers, such as GeoJSON.</p>
<p>Example of a multidimensional array:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">[ [<span class="hljs-number">3.1</span>,<span class="hljs-number">51.06</span>,<span class="hljs-number">30</span>],
  [<span class="hljs-number">3.1</span>,<span class="hljs-number">51.06</span>,<span class="hljs-number">20</span>] ]</pre></div>
<p>This issue is a result from the discussion on the GeoJSON-LD repository: <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="103497916" data-permission-text="Issue title is private" data-url="https://github.com/geojson/geojson-ld/issues/32" href="https://github.com/geojson/geojson-ld/issues/32">geojson/geojson-ld#32</a>. If this issue will not get resolved, the GeoJSON-LD community would suggest creating custom JSON-LD parsers for JSON-LD dialects. This situation would be far from desirable.</p>
<h2 id="suggested-solution">Suggested solution&nbsp;<span class="permalink"><a href="#issue-container-number-397" aria-label="Permalink for Suggested solution" title="Permalink for Suggested solution"><span>§</span></a></span></h2>
<p>Introduce a new  <code>@values</code> keyword, which can be used to describe the values of a <code>@set</code> or a <code>@list</code> container in more detail.</p>
<p>When an array is given in the <code>@values</code>, then the precise amount of objects within this array corresponds with the array in the graph in this order.</p>
<p>When an object is given in the <code>@values</code>, each value of the array in the graph is mapped according to this template.</p>
<h3 id="example">Example&nbsp;<span class="permalink"><a href="#issue-container-number-397" aria-label="Permalink for Example" title="Permalink for Example"><span>§</span></a></span></h3>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
     <span class="hljs-attr">"coordinates"</span>: {
        <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"geojson:coordinates"</span>,
        <span class="hljs-attr">"@container"</span> : <span class="hljs-string">"@list"</span>,
        <span class="hljs-attr">"@values"</span> : {
           <span class="hljs-attr">"@type"</span> : <span class="hljs-string">"geojson:Coordinate"</span>,
           <span class="hljs-attr">"@container"</span> : <span class="hljs-string">"@set"</span>,
           <span class="hljs-attr">"@values"</span> : [
               {<span class="hljs-attr">"@type"</span> : <span class="hljs-string">"xsd:double"</span>, <span class="hljs-attr">"@id"</span>:<span class="hljs-string">"geo:longitude"</span>},
               {<span class="hljs-attr">"@type"</span> : <span class="hljs-string">"xsd:double"</span>, <span class="hljs-attr">"@id"</span>:<span class="hljs-string">"geo:latitude"</span>}
           ]
        }
     }
  },
  <span class="hljs-attr">"@graph"</span> : [{
   <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"ex:LineString1"</span>,
    <span class="hljs-attr">"coordinates"</span> : [
          [
            <span class="hljs-number">3.1057405471801753</span>,
            <span class="hljs-number">51.064216229943476</span>
          ],
          [
            <span class="hljs-number">3.1056976318359375</span>,
            <span class="hljs-number">51.063434090307574</span>
          ]
    ]
  }]
}</pre></div>
<p>Would transform to (and vice versa):</p>
<div class="highlight highlight-source-turtle"><pre aria-busy="false" class="hljs css"><span class="hljs-selector-tag">ex</span><span class="hljs-selector-pseudo">:LineString1</span> <span class="hljs-selector-tag">geojson</span><span class="hljs-selector-pseudo">:coordinates</span> _<span class="hljs-selector-pseudo">:b0</span> .
_<span class="hljs-selector-pseudo">:b0</span> <span class="hljs-selector-tag">rdf</span><span class="hljs-selector-pseudo">:first</span> _<span class="hljs-selector-pseudo">:b1</span> .
_<span class="hljs-selector-pseudo">:b1</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">geojson</span><span class="hljs-selector-pseudo">:Coordinate</span> ;
      <span class="hljs-selector-tag">geo</span><span class="hljs-selector-pseudo">:longitude</span> "3<span class="hljs-selector-class">.105740547180175E0</span>"^^<span class="hljs-selector-tag">xsd</span><span class="hljs-selector-pseudo">:double</span> ;
      <span class="hljs-selector-tag">geo</span><span class="hljs-selector-pseudo">:latitude</span> "5<span class="hljs-selector-class">.106421622994348E1</span>"^^<span class="hljs-selector-tag">xsd</span><span class="hljs-selector-pseudo">:double</span> .
_<span class="hljs-selector-pseudo">:b0</span> <span class="hljs-selector-tag">rdf</span><span class="hljs-selector-pseudo">:rest</span> _<span class="hljs-selector-pseudo">:b2</span> .
_<span class="hljs-selector-pseudo">:b2</span> <span class="hljs-selector-tag">rdf</span><span class="hljs-selector-pseudo">:first</span> <span class="hljs-selector-tag">a</span> <span class="hljs-selector-tag">geojson</span><span class="hljs-selector-pseudo">:Coordinate</span> ;
      <span class="hljs-selector-tag">geo</span><span class="hljs-selector-pseudo">:longitude</span> "3<span class="hljs-selector-class">.1056976318359375</span>"^^<span class="hljs-selector-tag">xsd</span><span class="hljs-selector-pseudo">:double</span> ;
      <span class="hljs-selector-tag">geo</span><span class="hljs-selector-pseudo">:latitude</span> "51<span class="hljs-selector-class">.063434090307574</span>"^^<span class="hljs-selector-tag">xsd</span><span class="hljs-selector-pseudo">:double</span> .
_<span class="hljs-selector-pseudo">:b2</span> <span class="hljs-selector-tag">rdf</span><span class="hljs-selector-pseudo">:rest</span> <span class="hljs-selector-tag">rdf</span><span class="hljs-selector-pseudo">:nil</span> .</pre></div></div>
  <div class="issue" id="issue-container-number-402"><div role="heading" class="issue-title marker" id="h-issue-6" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/402"><span>Issue 402</span></a><span style="text-transform: none">: Relax the colliding keywords constraint for @type<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a></span></div><p>I want the following:</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"type"</span>: <span class="hljs-string">"@type"</span>,
    <span class="hljs-attr">"profile"</span>: <span class="hljs-string">"@type"</span>
  },
  <span class="hljs-attr">"type"</span>: <span class="hljs-string">"cov:Coverage"</span>,
  <span class="hljs-attr">"profile"</span>: <span class="hljs-string">"cov:GridCoverage"</span>
}</pre></div>
<p>However this is not allowed. The playground says "Invalid JSON-LD syntax; colliding keywords detected".</p>
<p>However, this one works:</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"type"</span>: {<span class="hljs-attr">"@id"</span>: <span class="hljs-string">"rdf:type"</span>, <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"@id"</span> },
    <span class="hljs-attr">"profile"</span>: {<span class="hljs-attr">"@id"</span>: <span class="hljs-string">"rdf:type"</span>, <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"@id"</span> }
  },
  <span class="hljs-attr">"type"</span>: <span class="hljs-string">"cov:Coverage"</span>,
  <span class="hljs-attr">"profile"</span>: <span class="hljs-string">"cov:GridCoverage"</span>
}</pre></div>
<p>I understand that this restriction probably makes sense for other keywords, but could it do any harm for <code>@type</code>?</p></div>
  <div class="issue" id="issue-container-number-434"><div role="heading" class="issue-title marker" id="h-issue-7" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/434"><span>Issue 434</span></a><span style="text-transform: none">: Streaming Profiles for JSON-LD to/from RDF<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a></span></div><p>There have been some discussions on what it would take to be able to do a streaming parse of JSON-LD into Quads, and similarly to generate compliant JSON-LD from a stream of quads. Describing these as some kind of a profile would be useful for implementations that expect to work in a streaming environment, when it's not feasible to work on an entire document basis.</p>
<p>As currently stated, the JSON-LD to RDF algorithm requires expanding the document and creating a node map. A profile of JSON-LD which used a flattened array of node objects, where each node object could be independently expanded and no flattening is required could facilitate deserializing an arbitrarily long JSON-LD source to Quads. (Some simplifying restrictions on shared lists may be necessary). Outer document is an object, containing <code>@context</code> and <code>@graph</code> only; obviously, this only will work for systems that can access key/values in order, and for systems that ensure that <code>@context</code> comes lexically before <code>@graph</code> in the output. Obviously, only implementations that can read and write JSON objects with key ordering intact will be able to take advantage of such streaming capability.</p>
<p>Fo serializing RDF to JSON-LD, expectations on the grouping of quads with the same graph name and subject are necessary to reduce serialization cost, and marshaling components of RDF Lists is likely not feasible. Even if graph name/subject grouping is not maintained in the input, the resulting output will still represent a valid JSON-LD document, although it may require flattening for further processing. (Many triple stores will, in fact, generate statements/quads properly grouped, so this is likely not an issue in real world applications).</p></div>
  <div class="issue" id="issue-container-number-460"><div role="heading" class="issue-title marker" id="h-issue-8" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/460"><span>Issue 460</span></a><span style="text-transform: none">: "Stratified" or "Dictionaried" API feature<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a></span></div><p>Hi there,</p>
<p>I was looking for a way to access properties in a JSON-LD document based on triples (to patch the document). This would mean having a view which creates a dictionary for a given document. The term Normalisation is already used, but this approach would be close to the way <a href="https://github.com/paularmstrong/normalizr">https://github.com/paularmstrong/normalizr</a>. D3 uses <a href="https://github.com/d3/d3-hierarchy/blob/master/README.md#stratify">https://github.com/d3/d3-hierarchy/blob/master/README.md#stratify</a> in a slightly different way but with the same general intent.</p>
<p>The goal would be to be able to address document values with this syntax <code>stratified_doc[triple.subject][triple.predicate]</code> or even better <code>stratified[triple.graph][triple.subject][triple.predicate]</code>.</p>
<p>This could also be a <code>@stratified</code> parameter for <code>expansion</code>.</p>
<h3 id="example-0">Example&nbsp;<span class="permalink"><a href="#issue-container-number-460" aria-label="Permalink for Example" title="Permalink for Example"><span>§</span></a></span></h3>
<p>For a document:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"dc"</span>: <span class="hljs-string">"http://purl.org/dc/elements/1.1/"</span>,
    <span class="hljs-attr">"ex"</span>: <span class="hljs-string">"http://example.org/vocab#"</span>,
    <span class="hljs-attr">"xsd"</span>: <span class="hljs-string">"http://www.w3.org/2001/XMLSchema#"</span>,
    <span class="hljs-attr">"ex:contains"</span>: {
      <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"@id"</span>
    }
  },
  <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://example.org/graph/0"</span>,
  <span class="hljs-attr">"dc:creator"</span>: <span class="hljs-string">"Jane Doe"</span>,
  <span class="hljs-attr">"@graph"</span>: [
    {
      <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://example.org/library"</span>,
      <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"ex:Library"</span>,
      <span class="hljs-attr">"ex:contains"</span>: <span class="hljs-string">"http://example.org/library/the-republic"</span>
    }
  ]
}</pre></div>
<p>Such a <code>stratified</code> would therefore look like:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"http://example.org/graph/0"</span>: {
   <span class="hljs-attr">"http://example.org/library"</span>: {
      <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"http://example.org/vocab#Library"</span>,
      <span class="hljs-attr">"http://example.org/vocab#contains"</span>: {
        <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://example.org/library/the-republic"</span>
      }
    },
    <span class="hljs-attr">"http://example.org/library/the-republic"</span>: {}
  },
  <span class="hljs-attr">"@graph"</span>: {
    <span class="hljs-attr">"http://example.org/graph/0"</span>: {
      <span class="hljs-attr">"http://purl.org/dc/elements/1.1/creator"</span>: <span class="hljs-string">"Jane Doe"</span>
    }
  }
}</pre></div>
<p>This would therefore allow to do the following:</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs javascript"><span class="hljs-comment">// Access a triple from the default graph</span>
<span class="hljs-keyword">var</span> creator = stratified[<span class="hljs-string">'@graph'</span>][<span class="hljs-string">'http://example.org/graph/0'</span>][<span class="hljs-string">'http://purl.org/dc/elements/1.1/creator'</span>];
<span class="hljs-comment">// "Jane Doe"</span>

<span class="hljs-comment">// Access a triple in a named graph</span>
<span class="hljs-keyword">var</span> type = stratified[<span class="hljs-string">'http://example.org/graph/0'</span>][<span class="hljs-string">'http://example.org/library'</span>][<span class="hljs-string">'@type'</span>];
<span class="hljs-comment">// "http://example.org/vocab#Library"</span>

<span class="hljs-comment">// Before submitting a document, mutate a property</span>
stratified[<span class="hljs-string">'http://example.org/graph/0'</span>][<span class="hljs-string">'http://example.org/library/the-republic'</span>][<span class="hljs-string">'@type'</span>] = <span class="hljs-string">'http://example.org/vocab#Book'</span>;

<span class="hljs-comment">// Or using an immutable spread syntax approach</span>
<span class="hljs-keyword">var</span> new_doc = {
  ...stratified,
  <span class="hljs-string">'http://example.org/graph/0'</span>: {
    ...stratified[<span class="hljs-string">'http://example.org/graph/0'</span>],
    <span class="hljs-string">'http://example.org/library/the-republic'</span> : {
      ...stratified[<span class="hljs-string">'http://example.org/graph/0'</span>][<span class="hljs-string">'http://example.org/library/the-republic'</span>],
      <span class="hljs-string">'@type'</span>: <span class="hljs-string">'http://example.org/vocab#Book'</span>
    }
  }
}</pre></div></div>
  <div class="issue" id="issue-container-number-507"><div role="heading" class="issue-title marker" id="h-issue-9" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/507"><span>Issue 507</span></a><span style="text-transform: none">: JSON-LD 1.1: method to require {"id": "uri"} resource compaction result<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a></span></div><p><strong>Issue:</strong> The compaction algorithm prefers the most compact format, which for resources without relationships is a string containing the URI.  This causes problems in systems that cannot handle arrays of mixed data types (for example ElasticSearch) when there are also resources that have relationships, resulting in both objects and strings in the same array.</p>
<p>For example:</p>
<pre aria-busy="false" class="hljs javascript"><span class="hljs-string">"seeAlso"</span>: [
    <span class="hljs-string">"http://example.org/reference1"</span>,
    {<span class="hljs-string">"id"</span>: <span class="hljs-string">"http://example.org/reference2"</span>, <span class="hljs-string">"format"</span>: <span class="hljs-string">"text/html"</span>}
  ]
</pre>
<p>would raise an error in Elastic.</p>
<p><strong>Proposed solution:</strong> Provide a flag to the compaction algorithm to signal that the resulting JSON should always create objects for resources, even if there is only the URI available.  This would instead render the example above as an array of objects:</p>
<pre aria-busy="false" class="hljs javascript"><span class="hljs-string">"seeAlso"</span>: [
    {<span class="hljs-string">"id"</span>: <span class="hljs-string">"http://example.org/reference1"</span>},
    {<span class="hljs-string">"id"</span>: <span class="hljs-string">"http://example.org/reference2"</span>, <span class="hljs-string">"format"</span>: <span class="hljs-string">"text/html"</span>}
  ]
</pre></div>
  <div class="issue" id="issue-container-number-512"><div role="heading" class="issue-title marker" id="h-issue-10" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/512"><span>Issue 512</span></a><span style="text-transform: none">: @type as @container:@set?<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a></span></div><p>The purpose of the <code>@container:@set</code> functionality (AFAIU) is to ensure that the output is consistent in shape. Thus if there can ever be multiple values, the structure is always an array.</p>
<p>There are two situations in which this functionality could be desirable but is currently not possible:</p>
<ol>
<li><code>@type</code> As it's a keyword, we can only alias it (e.g. as <code>type</code>) but not define it to have <code>@container:@set</code> functionality. Meaning that there's a gotcha waiting to happen for ontologies that require or use multiple classes for a single resource instance. See <a href="https://json-ld.org/playground/#startTab=tab-compacted&amp;json-ld=%7B%22%40context%22%3A%7B%22cls%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2Fclass%22%7D%2C%22type%22%3A%7B%22%40id%22%3A%22%40type%22%2C%22%40container%22%3A%22%40set%22%7D%7D%2C%22%40id%22%3A%22foo%22%2C%22type%22%3A%22cls%22%7D&amp;context=%7B%22%40context%22%3A%7B%22cls%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2Fclass%22%7D%2C%22type%22%3A%7B%22%40id%22%3A%22%40type%22%2C%22%40container%22%3A%22%40set%22%7D%7D%7D" rel="nofollow">playground</a></li>
<li><code>@context</code> Less useful, but <code>@context</code> will also compact to a single string/object when there might be multiple contexts.  See <a href="https://json-ld.org/playground/#startTab=tab-compacted&amp;copyContext=true&amp;json-ld=%7B%22%40context%22%3A%5B%7B%22cls%22%3A%7B%22%40id%22%3A%22http%3A%2F%2Fexample.org%2Fclass%22%7D%2C%22type%22%3A%7B%22%40id%22%3A%22%40type%22%2C%22%40container%22%3A%22%40set%22%7D%7D%5D%2C%22%40id%22%3A%22foo%22%2C%22type%22%3A%22cls%22%7D" rel="nofollow">playground</a></li>
</ol>
<p><code>@context</code> modifying itself seems particularly strange, but the inconsistency for <code>@type</code> seems solvable if the restrictions in its definition were loosened?</p></div>
  <div class="issue" id="issue-container-number-526"><div role="heading" class="issue-title marker" id="h-issue-11" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/526"><span>Issue 526</span></a><span style="text-transform: none">: precedence of @vocab for compaction too strong?<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a></span></div><p>This is related to <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="12631696" data-permission-text="Issue title is private" data-url="https://github.com/json-ld/json-ld.org/issues/235" href="https://github.com/json-ld/json-ld.org/issues/235">#235</a>: When I have the following document:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"@vocab"</span>  : <span class="hljs-string">"http://vocab.getty.edu/"</span>,
    <span class="hljs-attr">"a"</span>     : <span class="hljs-string">"http://vocab.getty.edu/aaaaaaaaaat/"</span>
  },
  <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"http://vocab.getty.edu/aaaaaaaaaat/5001065997"</span>,
  <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"http://vocab.getty.edu/aaaaaaaaaat/datatype"</span>
}</pre></div>
<p>By point <code>3</code> of the spec, because <code>http://vocab.getty.edu/aaaaaaaaaat/5001065997</code> contains the value of <code>@vocab</code>, it gets compacted as <code>aaaaaaaaaat/5001065997</code> without even looking at the prefixes. I think this is not reasonable, in this case <code>a:5001065997</code> would look much nicer IMO.</p></div>
  <div class="issue" id="issue-container-number-530"><div role="heading" class="issue-title marker" id="h-issue-12" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/530"><span>Issue 530</span></a><span style="text-transform: none">: Losing Last Element in RDF List<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22question%22" style="background-color: rgb(199, 222, 248);">question</a></span></div><p>We have web application that needs to be able to modify RDF lists from a triple store and propagate the changes back. To do this, we are utilizing <a href="https://github.com/jsonld-java/jsonld-java">jsonld-java</a> to serialize the RDF into JSON-LD, modifying it in the web app, and then sending it back to be deserialized and stored in the triple store. Originally, we were using blank nodes like the ones shown in Turtle below.</p>
<pre aria-busy="false" class="hljs javascript">&lt;http:<span class="hljs-comment">//example.com&gt; &lt;http://example.com/property&gt; _:a .</span>
_:a a &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#List&gt; ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#first&gt; "a" ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#rest&gt; _:b .</span>
_:b a &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#List&gt; ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#first&gt; "b" ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#rest&gt; _:c .</span>
_:c a &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#List&gt; ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#first&gt; "c" ;</span>
    &lt;http:<span class="hljs-comment">//www.w3.org/1999/02/22-rdf-syntax-ns#rest&gt; &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#nil&gt; .</span>
</pre>
<p>However, we discovered that blank node lists are collapsed during serialization thus losing all the blank node IDs.</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs json">[ {
  <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"http://example.com"</span>,
  <span class="hljs-attr">"http://example.com/property"</span> : [ {
    <span class="hljs-attr">"@list"</span> : [ {
      <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"a"</span>
    }, {
      <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"b"</span>
    }, {
      <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"c"</span>
    } ]
  } ]
} ]</pre></div>
<p>With blank node IDs removed, we are no longer able to reference the existing RDF in the triple store to perform updates when the lists are modified in the web-app without much more complex logic. To avoid this, we skolemized the blank node IDs into IRIs.</p>
<pre aria-busy="false" class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.com</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">example.com</span>/<span class="hljs-attr">property</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">urn:a</span>&gt;</span> .
<span class="hljs-tag">&lt;<span class="hljs-name">urn:a</span>&gt;</span> a <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">List</span>&gt;</span> ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">first</span>&gt;</span> "a" ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">rest</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">urn:b</span>&gt;</span> .
<span class="hljs-tag">&lt;<span class="hljs-name">urn:b</span>&gt;</span> a <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">List</span>&gt;</span> ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">first</span>&gt;</span> "b" ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">rest</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">urn:c</span>&gt;</span> .
<span class="hljs-tag">&lt;<span class="hljs-name">urn:c</span>&gt;</span> a <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">List</span>&gt;</span> ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">first</span>&gt;</span> "c" ;
    <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">rest</span>&gt;</span> <span class="hljs-tag">&lt;<span class="hljs-name">http:</span>//<span class="hljs-attr">www.w3.org</span>/<span class="hljs-attr">1999</span>/<span class="hljs-attr">02</span>/<span class="hljs-attr">22-rdf-syntax-ns</span>#<span class="hljs-attr">nil</span>&gt;</span> .
</pre>
<p>However, when serializing the skolemized triples, the IRI for the last element in the RDF list is hidden, in this case <code>urn:c</code>. This leads to the same problem we were having when using blank node IDs.</p>
<div class="highlight highlight-source-js"><pre aria-busy="false" class="hljs json">[ {
  <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"http://example.com"</span>,
  <span class="hljs-attr">"http://example.com/property"</span> : [ {
    <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"urn:a"</span>
  } ]
}, {
  <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"urn:a"</span>,
  <span class="hljs-attr">"@type"</span> : [ <span class="hljs-string">"http://www.w3.org/1999/02/22-rdf-syntax-ns#List"</span> ],
  <span class="hljs-attr">"http://www.w3.org/1999/02/22-rdf-syntax-ns#first"</span> : [ {
    <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"a"</span>
  } ],
  <span class="hljs-attr">"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"</span> : [ {
    <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"urn:b"</span>
  } ]
}, {
  <span class="hljs-attr">"@id"</span> : <span class="hljs-string">"urn:b"</span>,
  <span class="hljs-attr">"@type"</span> : [ <span class="hljs-string">"http://www.w3.org/1999/02/22-rdf-syntax-ns#List"</span> ],
  <span class="hljs-attr">"http://www.w3.org/1999/02/22-rdf-syntax-ns#first"</span> : [ {
    <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"b"</span>
  } ],
  <span class="hljs-attr">"http://www.w3.org/1999/02/22-rdf-syntax-ns#rest"</span> : [ {
    <span class="hljs-attr">"@list"</span> : [ {
      <span class="hljs-attr">"@value"</span> : <span class="hljs-string">"c"</span>
    } ]
  } ]
} ]</pre></div>
<p>Issue <a class="issue-link js-issue-link" data-error-text="Failed to load issue title" data-id="16395407" data-permission-text="Issue title is private" data-url="https://github.com/json-ld/json-ld.org/issues/277" href="https://github.com/json-ld/json-ld.org/issues/277">#277</a>   seems to be the point where the implementation changed from serializing lists in the manner we expect to this new compact way. Is there any way we can get around this so that the last blank node of a list is not collapsed?</p></div>
  <div class="issue" id="issue-container-number-542"><div role="heading" class="issue-title marker" id="h-issue-13" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/542"><span>Issue 542</span></a><span style="text-transform: none">: Feature request: Could framing return properties in the order listed by the frame? <a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22framing%22" style="background-color: rgb(68, 68, 68);">framing</a></span></div><p>Currently it appears that properties are sorted into alphabetical order after any JSON-LD operation (compaction, framing).</p>
<p>In the context of framing, this is sometimes a nice feature, since it means that after framing multiple input JSON files, the JSON data is at least in a consistent order.</p>
<p>I understand that ordering is semantically meaningless, but as framing exists to turn the graph (which could correspond to multiple different trees) into a predictable JSON tree as a convenience for developers, it seems natural to me that if an explicit ordering is given in the frame, that the algorithm would respect that order rather than alphabetize.  For example, if my data is:</p>
<pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: <span class="hljs-string">"http://schema.org/"</span>,
  <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"document"</span>,
  <span class="hljs-attr">"b"</span>: <span class="hljs-string">"text"</span>,
  <span class="hljs-attr">"a"</span>: <span class="hljs-string">"more text"</span>

}
</pre>
<p>Under the frame:</p>
<pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: <span class="hljs-string">"http://schema.org/"</span>,
  <span class="hljs-attr">"@id"</span>:  <span class="hljs-string">"document"</span>,
  <span class="hljs-attr">"b"</span>: {},
  <span class="hljs-attr">"a"</span>: {}
}
</pre>
<p>(<a href="http://tinyurl.com/ybj7k25f" rel="nofollow">example in playground</a>)</p>
<p>the returned document reverses the order of <code>b</code> and <code>a</code> (to be alphabetical), and not the order given in the frame.  Framing is a really elegant way to specify the nesting order, but it would be nice for framing to also be able to dictate the ordering, so that the output data file really follows the exact structure of the given frame.</p>
<p>Related issue: there is no way to indicate that referenced nodes should occur before they are references (excluding circular references), which can be useful in streaming files.  Having control of the node order via the frame would also give a mechanism to address that.</p>
<p>Hope this makes sense and apologies if I'm missing something fundamental here that makes alphabetizing the node order the only logical thing to do; or if I've misunderstood the expected behavior.</p></div>
  <div class="issue" id="issue-container-number-548"><div role="heading" class="issue-title marker" id="h-issue-14" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/548"><span>Issue 548</span></a><span style="text-transform: none">: Use version 2.0 instead of 1.1<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p><a href="https://json-ld.org/minutes/2017-11-08/" rel="nofollow">Comments at TPAC</a> suggested that as our work is a breaking change (causing 1.0 processors that are not 1.1 compatible to intentionally break when they see <code>"@version": 1.1</code>), <a href="http://semver.org" rel="nofollow">semantic versioning</a> would suggest that we use a major release number, rather than a minor number.</p>
<p>This could impact a potential WG, which may want to make further changes, and then be in the place of using either <code>2.1</code> or <code>3.0</code>, which is odd given that the previous recommendation is <code>1.0</code>.</p></div>
  <div class="issue" id="issue-container-number-583"><div role="heading" class="issue-title marker" id="h-issue-15" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/583"><span>Issue 583</span></a><span style="text-transform: none">: Introducing @dir ?<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>In some situations it is important/necessary to include the base direction of a text, alongside its language; see the <a href="https://w3c.github.io/string-meta/" rel="nofollow">“Requirements for Language and Direction Metadata in Data Formats”</a> for further details. In practice, in a vanilla JSON, it would require something like:</p>
<pre aria-busy="false" class="hljs javascript"><span class="hljs-string">"title"</span>: [ { <span class="hljs-string">"value"</span>: <span class="hljs-string">"Moby Dick"</span>, <span class="hljs-string">"lang"</span>: <span class="hljs-string">"en"</span> },
           { <span class="hljs-string">"value"</span>: <span class="hljs-string">"موبي ديك"</span>, <span class="hljs-string">"lang"</span>: <span class="hljs-string">"ar"</span>  <span class="hljs-string">"dir"</span>: <span class="hljs-string">"rtl"</span>}
         ]
</pre>
<p>(the example comes from that document).</p>
<p>At this moment, I believe the only way you can reasonably express that in JSON-LD is via cheating a bit:</p>
<pre aria-busy="false" class="hljs javascript"><span class="hljs-string">"title"</span>: [ { <span class="hljs-string">"@value"</span>: <span class="hljs-string">"Moby Dick"</span>, <span class="hljs-string">"@language"</span>: <span class="hljs-string">"en"</span> },
           { <span class="hljs-string">"@value"</span>: <span class="hljs-string">"موبي ديك"</span>,  <span class="hljs-string">"@language"</span>: <span class="hljs-string">"ar"</span>  <span class="hljs-string">"dir"</span>: <span class="hljs-string">"rtl"</span>}
         ]
</pre>
<p>and making sure that the <code>dir</code> term is <em>not</em> defined in the relevant <code>@context</code> so that, when generating the RDF output, that term is simply ignored. But that also means that there is no round-tripping, that term will disappear after expansion.</p>
<p>The difficulty lies in the RDF layer, in fact; RDF does not have any means (alas!) to express text direction. On the other hand, this missing feature is a general I18N problem whenever JSON-LD is used (there were issues when developing the Web Annotation Model, these issues are popping up in the Web Publication work, etc.).</p>
<p>Here is what I would propose as a non-complete solution</p>
<ol>
<li>Let us introduce a <code>@dir</code> term, alongside <code>@language</code>. This means this term can be used in place of <code>dir</code> above, ie, it is a bona-fide part of a string representation, and would therefore be kept in the compaction/expansion steps, can also be used for framing.</li>
<li>In JSON-LD 1.1, <code>@dir</code> is <em>ignored</em> when transforming into RDF. I.e., only the language tag would be used.</li>
<li>We <em>may</em> initiate some work in the RDF community to solve this issue. There may be several ways, each of them require the RDF community to chime in<br>
3.1. Define a mechanism of "parametrized" standard datatypes that represent a (language,direction) pair. One would then get something like<code>[] ex:title "موبي ديك"^^rdf:internationalText(ar,rtl) ;</code><br>
3.2. Go for a "generalized" RDF where strings can also appear as subjects (that has been a matter of dispute for a long time...). That would give the possibility to add such attribute to texts like directions<br>
3.3. Some other mechanisms that I cannot think about</li>
<li>In a future JSON-LD 1.* the <code>@dir</code> value can be properly mapped onto an RDF representing the right choices (if such choices are worked out)</li>
</ol>
<p>Cc: <a class="user-mention" data-hovercard-user-id="43209" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/BigBlueHat">@BigBlueHat</a> <a class="user-mention" data-hovercard-user-id="4839211" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/r12a">@r12a</a></p></div>
  <div class="issue" id="issue-container-number-595"><div role="heading" class="issue-title marker" id="h-issue-16" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/595"><span>Issue 595</span></a><span style="text-transform: none">: Native support for schema:ListItem<a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22api%22" style="background-color: rgb(245, 169, 242);">api</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22defer%22" style="background-color: rgb(0, 82, 204);">defer</a><a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22spec-design%22" style="background-color: rgb(225, 12, 2);">spec-design</a><a class="respec-gh-label respec-label-light" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22syntax%22" style="background-color: rgb(255, 255, 0);">syntax</a></span></div><p>Per a suggestion by <a class="user-mention" data-hovercard-user-id="170265" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/danbri">@danbri</a>, we may want to add a container type, similar to <code>@list</code> for encoding <a href="http://schema.org/ItemList" rel="nofollow"><code>schema:ItemList</code></a> serializations, when the values are <a href="http://schema.org/ListItem" rel="nofollow"><code>schema:ListItem</code></a> and order is set through <code>schema:position</code>. <code>ItemList</code> can be used with text values as well, but this is already reasonably supported natively.</p>
<p>Markup might look like the following:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">{
  <span class="hljs-attr">"@context"</span>: {
    <span class="hljs-attr">"@vocab"</span>: <span class="hljs-string">"http://schema.org/"</span>,
    <span class="hljs-attr">"itemListElement"</span>: {<span class="hljs-attr">"@container"</span>: <span class="hljs-string">"@listItem"</span>}
  },
  <span class="hljs-attr">"@type"</span>: <span class="hljs-string">"ItemList"</span>,
  <span class="hljs-attr">"@url"</span>: <span class="hljs-string">"http://en.wikipedia.org/wiki/Billboard_200"</span>,
  <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Top music artists"</span>,
  <span class="hljs-attr">"description"</span>: <span class="hljs-string">"The artists with the most cumulative weeks at number one according to Billboard 200"</span>,
  <span class="hljs-attr">"itemListElement"</span>: [
    {<span class="hljs-attr">"@type"</span>: <span class="hljs-string">"MusicGroup"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Beatles"</span>},
    {<span class="hljs-attr">"@type"</span>: <span class="hljs-string">"MusicGroup"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Elvis Presley"</span>},
    {<span class="hljs-attr">"@type"</span>: <span class="hljs-string">"MusicGroup"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Michael Jackson"</span>},
    {<span class="hljs-attr">"@type"</span>: <span class="hljs-string">"MusicGroup"</span>, <span class="hljs-attr">"name"</span>: <span class="hljs-string">"Garth Brooks"</span> }
  ]</pre></div>
<p>This would expand to the following:</p>
<div class="highlight highlight-source-json"><pre aria-busy="false" class="hljs json">[
  {
    <span class="hljs-attr">"@id"</span>: <span class="hljs-string">"http://en.wikipedia.org/wiki/Billboard_200"</span>,
    <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/ItemList"</span>],
    <span class="hljs-attr">"http://schema.org/description"</span>: [{
      <span class="hljs-attr">"@value"</span>: <span class="hljs-string">"The artists with the most cumulative weeks at number one according to Billboard 200"</span>
    }],
    <span class="hljs-attr">"http://schema.org/itemListElement"</span>: [{
      <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/ListItem"</span>],
      <span class="hljs-attr">"http://schema.org/item"</span>: [{
        <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/MusicGroup"</span>],
        <span class="hljs-attr">"http://schema.org/name"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-string">"Beatles"</span>}]
      }],
      <span class="hljs-attr">"http://schema.org/position"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-number">1</span>}]
    },  {
      <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/ListItem"</span>],
      <span class="hljs-attr">"http://schema.org/item"</span>: [{
        <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/MusicGroup"</span>],
        <span class="hljs-attr">"http://schema.org/name"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-string">"Elvis Presley"</span>}]
      }],
      <span class="hljs-attr">"http://schema.org/position"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-number">2</span>}]
    }, {
      <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/ListItem"</span>],
      <span class="hljs-attr">"http://schema.org/item"</span>: [{
        <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/MusicGroup"</span>],
        <span class="hljs-attr">"http://schema.org/name"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-string">"Michael Jackson"</span>}]
      }],
      <span class="hljs-attr">"http://schema.org/position"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-number">3</span>}]
    }, {
      <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/ListItem"</span>],
      <span class="hljs-attr">"http://schema.org/item"</span>: [{
        <span class="hljs-attr">"@type"</span>: [<span class="hljs-string">"http://schema.org/MusicGroup"</span>],
        <span class="hljs-attr">"http://schema.org/name"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-string">"Garth Brooks"</span>}]
      }],
      <span class="hljs-attr">"http://schema.org/position"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-number">3</span>}]
    }
  ],
  <span class="hljs-attr">"http://schema.org/name"</span>: [{<span class="hljs-attr">"@value"</span>: <span class="hljs-string">"Top music artists"</span>}]
}]</pre></div>
<p>Otherwise, it works like <code>@list</code>.</p>
<p>When compacting, the processor will re-order items based on <code>position</code>, and ignore any <code>nextItem</code> or <code>previousItem</code> entries.</p>
<p>Expansion shows 1-base position, but could be 0-base as well. Note that specific <code>position</code> values are lost when compacting, and duplicate values may lead to undefined relative ordering.</p></div>
  <div class="issue" id="issue-container-number-589"><div role="heading" class="issue-title marker" id="h-issue-17" aria-level="3"><a href="https://github.com/json-ld/json-ld.org/issues/589"><span>Issue 589</span></a><span style="text-transform: none">: JSON-LD version on playground<a class="respec-gh-label respec-label-dark" href="https://github.com/json-ld/json-ld.org//issues/?q=is%3Aissue+is%3Aopen+label%3A%22playground%22" style="background-color: rgb(17, 170, 17);">playground</a></span></div><p>During the last meeting it was <a href="https://json-ld.org/minutes/2018-02-05/#resolution-1" rel="nofollow">resolved</a> to have one playground for 1.0 and 1.1 processing.  Some notes on that related to <a href="https://github.com/digitalbazaar/jsonld.js">jsonld.js</a>:</p>
<ul>
<li>0.4.x passes older 1.0 test suites</li>
<li>0.4.x does not pass more recent tests added for 1.0</li>
<li>0.5.x does pass all current 1.0 tests</li>
<li>0.5.x also includes a bit of 1.1 functionality, in particular some <code>@graph</code> handling and a bit of <code>@version</code> handling</li>
<li>0.6.x should end up passing all 1.0 and current 1.1 draft tests</li>
<li>there <em>may</em> be technical issues using multiple jsonld.js versions on one page</li>
</ul>
<p>From an ease of site development viewpoint, I think we should just put the most recent jsonld.js on the playground and add a UI control to pick the <code>processingMode</code> API option.  Due to practicalities of jsonld.js not having a full correct 1.0 <em>only</em> lib, it seems not worth the effort to try and deal with this any other way.  There are edge cases where a 1.1 lib in 1.0 mode will produce different results than a 1.0 lib.  My guess is that in practice this really doesn't matter.  Or in any case, is not worth handling on the playground.</p></div>
</section>

<section class="appendix informative" id="acknowledgements">
  <!--OddPage--><h2 id="e-acknowledgements"><span class="secno">E. </span>Acknowledgements&nbsp;<span class="permalink"><a href="#acknowledgements" aria-label="Permalink for E. Acknowledgements" title="Permalink for E. Acknowledgements"><span>§</span></a></span></h2><p><em>This section is non-normative.</em></p>

  <p>A large amount of thanks goes out to the JSON-LD Community Group
    participants who worked through many of the technical issues on the mailing
    list and the weekly telecons - of special mention are Niklas Lindström,
    François Daoust, Lin Clark, and Zdenko 'Denny' Vrandečić.
    The editors would like to thank Mark Birbeck, who provided a great deal of
    the initial push behind the JSON-LD work via his work on RDFj.
    The work of Dave Lehn and Mike Johnson are appreciated for reviewing,
    and performing several implementations of the specification. Ian Davis is
    thanked for his work on RDF/JSON. Thanks also to Nathan Rixham,
    Bradley P. Allen, Kingsley Idehen, Glenn McDonald, Alexandre Passant,
    Danny Ayers, Ted Thibodeau Jr., Olivier Grisel, Josh Mandel, Eric Prud'hommeaux,
    David Wood, Guus Schreiber, Pat Hayes, Sandro Hawke, and Richard Cyganiak
    for their input on the specification.</p>
</section>



<section id="references" class="appendix"><!--OddPage--><h2 id="f-references"><span class="secno">F. </span>References&nbsp;<span class="permalink"><a href="#references" aria-label="Permalink for F. References" title="Permalink for F. References"><span>§</span></a></span></h2><section id="normative-references"><h3 id="f-1-normative-references"><span class="secno">F.1 </span>Normative references&nbsp;<span class="permalink"><a href="#normative-references" aria-label="Permalink for F.1 Normative references" title="Permalink for F.1 Normative references"><span>§</span></a></span></h3><dl class="bibliography"><dt id="bib-BCP47">[BCP47]</dt><dd><a href="https://tools.ietf.org/html/bcp47"><cite>Tags for Identifying Languages</cite></a>. A. Phillips; M. Davis. IETF. September 2009. IETF Best Current Practice. URL: <a href="https://tools.ietf.org/html/bcp47">https://tools.ietf.org/html/bcp47</a>
</dd><dt id="bib-IEEE-754-2008">[IEEE-754-2008]</dt><dd><a href="http://standards.ieee.org/findstds/standard/754-2008.html"><cite>IEEE 754-2008 Standard for Floating-Point Arithmetic</cite></a>.  Institute of Electrical and Electronics Engineers. 2008. URL: <a href="http://standards.ieee.org/findstds/standard/754-2008.html">http://standards.ieee.org/findstds/standard/754-2008.html</a>
</dd><dt id="bib-JSON-LD">[JSON-LD]</dt><dd><a href="https://www.w3.org/TR/json-ld/"><cite>JSON-LD 1.0</cite></a>. Manu Sporny; Gregg Kellogg; Markus Lanthaler. W3C. 16 January 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/json-ld/">https://www.w3.org/TR/json-ld/</a>
</dd><dt id="bib-JSON-LD11CG">[JSON-LD11CG]</dt><dd><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/"><cite>JSON-LD 1.1</cite></a>. Gregg Kellogg. W3C. CG Final. URL: <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld/">https://www.w3.org/2018/jsonld-cg-reports/json-ld/</a>
</dd><dt id="bib-RDF-CONCEPTS">[RDF-CONCEPTS]</dt><dd><a href="https://www.w3.org/TR/rdf-concepts/"><cite>Resource Description Framework (RDF): Concepts and Abstract Syntax</cite></a>. Graham Klyne; Jeremy Carroll. W3C. 10 February 2004. W3C Recommendation. URL: <a href="https://www.w3.org/TR/rdf-concepts/">https://www.w3.org/TR/rdf-concepts/</a>
</dd><dt id="bib-RDF11-MT">[RDF11-MT]</dt><dd><a href="https://www.w3.org/TR/rdf11-mt/"><cite>RDF 1.1 Semantics</cite></a>. Patrick Hayes; Peter Patel-Schneider. W3C. 25 February 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/rdf11-mt/">https://www.w3.org/TR/rdf11-mt/</a>
</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd><a href="https://tools.ietf.org/html/rfc2119"><cite>Key words for use in RFCs to Indicate Requirement Levels</cite></a>. S. Bradner. IETF. March 1997. Best Current Practice. URL: <a href="https://tools.ietf.org/html/rfc2119">https://tools.ietf.org/html/rfc2119</a>
</dd><dt id="bib-RFC3986">[RFC3986]</dt><dd><a href="https://tools.ietf.org/html/rfc3986"><cite>Uniform Resource Identifier (URI): Generic Syntax</cite></a>. T. Berners-Lee; R. Fielding; L. Masinter. IETF. January 2005. Internet Standard. URL: <a href="https://tools.ietf.org/html/rfc3986">https://tools.ietf.org/html/rfc3986</a>
</dd><dt id="bib-RFC3987">[RFC3987]</dt><dd><a href="https://tools.ietf.org/html/rfc3987"><cite>Internationalized Resource Identifiers (IRIs)</cite></a>. M. Duerst; M. Suignard. IETF. January 2005. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc3987">https://tools.ietf.org/html/rfc3987</a>
</dd><dt id="bib-RFC5988">[RFC5988]</dt><dd><a href="https://tools.ietf.org/html/rfc5988"><cite>Web Linking</cite></a>. M. Nottingham. IETF. October 2010. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc5988">https://tools.ietf.org/html/rfc5988</a>
</dd><dt id="bib-RFC7159">[RFC7159]</dt><dd><a href="https://tools.ietf.org/html/rfc7159"><cite>The JavaScript Object Notation (JSON) Data Interchange Format</cite></a>. T. Bray, Ed.. IETF. March 2014. Proposed Standard. URL: <a href="https://tools.ietf.org/html/rfc7159">https://tools.ietf.org/html/rfc7159</a>
</dd><dt id="bib-XMLSCHEMA11-2">[XMLSCHEMA11-2]</dt><dd><a href="https://www.w3.org/TR/xmlschema11-2/"><cite>W3C XML Schema Definition Language (XSD) 1.1 Part 2: Datatypes</cite></a>. David Peterson; Sandy Gao; Ashok Malhotra; Michael Sperberg-McQueen; Henry Thompson; Paul V. Biron et al. W3C. 5 April 2012. W3C Recommendation. URL: <a href="https://www.w3.org/TR/xmlschema11-2/">https://www.w3.org/TR/xmlschema11-2/</a>
</dd></dl></section><section id="informative-references"><h3 id="f-2-informative-references"><span class="secno">F.2 </span>Informative references&nbsp;<span class="permalink"><a href="#informative-references" aria-label="Permalink for F.2 Informative references" title="Permalink for F.2 Informative references"><span>§</span></a></span></h3><dl class="bibliography"><dt id="bib-ECMASCRIPT-6.0">[ECMASCRIPT-6.0]</dt><dd><a href="http://www.ecma-international.org/ecma-262/6.0/index.html"><cite>ECMA-262 6th Edition, The ECMAScript 2015 Language Specification</cite></a>. Allen Wirfs-Brock. Ecma International. June 2015. Standard. URL: <a href="http://www.ecma-international.org/ecma-262/6.0/index.html">http://www.ecma-international.org/ecma-262/6.0/index.html</a>
</dd><dt id="bib-JSON-LD-API">[JSON-LD-API]</dt><dd><a href="https://www.w3.org/TR/json-ld-api/"><cite>JSON-LD 1.0 Processing Algorithms and API</cite></a>. Markus Lanthaler; Gregg Kellogg; Manu Sporny. W3C. 16 January 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/json-ld-api/">https://www.w3.org/TR/json-ld-api/</a>
</dd><dt id="bib-JSON-LD-TESTS">[JSON-LD-TESTS]</dt><dd><a href="https://json-ld.org/test-suite/"><cite>JSON-LD 1.1 Test Suite</cite></a>. Gregg Kellogg. Linking Data in JSON Community Group. URL: <a href="https://json-ld.org/test-suite/">https://json-ld.org/test-suite/</a>
</dd><dt id="bib-JSON-LD11CG-API">[JSON-LD11CG-API]</dt><dd><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/"><cite>JSON-LD 1.1 Processing Algorithms and API</cite></a>. Gregg Kellogg. W3C. CG Final. URL: <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/">https://www.w3.org/2018/jsonld-cg-reports/json-ld-api/</a>
</dd><dt id="bib-JSON-LD11CG-FRAMING">[JSON-LD11CG-FRAMING]</dt><dd><a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/"><cite>JSON-LD 1.1 Framing</cite></a>. Gregg Kellogg. W3C. CG Final. URL: <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/">https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/</a>
</dd><dt id="bib-promises-guide">[promises-guide]</dt><dd><a href="https://www.w3.org/2001/tag/doc/promises-guide"><cite>Writing Promise-Using Specifications</cite></a>. Domenic Denicola. W3C. 16 February 2016. Finding of the W3C TAG. URL: <a href="https://www.w3.org/2001/tag/doc/promises-guide">https://www.w3.org/2001/tag/doc/promises-guide</a>
</dd><dt id="bib-RDF-SCHEMA">[RDF-SCHEMA]</dt><dd><a href="https://www.w3.org/TR/rdf-schema/"><cite>RDF Schema 1.1</cite></a>. Dan Brickley; Ramanathan Guha. W3C. 25 February 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/rdf-schema/">https://www.w3.org/TR/rdf-schema/</a>
</dd><dt id="bib-RDF11-CONCEPTS">[RDF11-CONCEPTS]</dt><dd><a href="https://www.w3.org/TR/rdf11-concepts/"><cite>RDF 1.1 Concepts and Abstract Syntax</cite></a>. Richard Cyganiak; David Wood; Markus Lanthaler. W3C. 25 February 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/rdf11-concepts/">https://www.w3.org/TR/rdf11-concepts/</a>
</dd><dt id="bib-RFC6839">[RFC6839]</dt><dd><a href="https://tools.ietf.org/html/rfc6839"><cite>Additional Media Type Structured Syntax Suffixes</cite></a>. T. Hansen; A. Melnikov. IETF. January 2013. Informational. URL: <a href="https://tools.ietf.org/html/rfc6839">https://tools.ietf.org/html/rfc6839</a>
</dd><dt id="bib-TURTLE">[TURTLE]</dt><dd><a href="https://www.w3.org/TR/turtle/"><cite>RDF 1.1 Turtle</cite></a>. Eric Prud'hommeaux; Gavin Carothers. W3C. 25 February 2014. W3C Recommendation. URL: <a href="https://www.w3.org/TR/turtle/">https://www.w3.org/TR/turtle/</a>
</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd><a href="https://heycam.github.io/webidl/"><cite>Web IDL</cite></a>. Cameron McCormack; Boris Zbarsky; Tobie Langel. W3C. 15 December 2016. W3C Editor's Draft. URL: <a href="https://heycam.github.io/webidl/">https://heycam.github.io/webidl/</a>
</dd></dl></section></section><p role="navigation" id="back-to-top"><a href="#title"><abbr title="Back to Top">↑</abbr></a></p><script src="https://www.w3.org/scripts/TR/2016/fixup.js"></script></body></html>
